X Assignment 18 to 20
X Assignment 18 to 20
: ___________________
Roll No. : _______ Date:______________ Term : I Assignment No: 18 to 20
Subject: Computer Applications Topic: Assignment Questions
Instructions:
➔ Use double-sided ruled A4 size project sheets.
➔ Write Questions using black pen.
➔ Write the program and VDT using a blue pen.
➔ These assignments are to be arranged after assignment 17 in proper sequence in the
Grade X Assignments file.
Assignment No 18:
S Question 1:
Write a program to generate the following pattern using switch-case statements.
Enter 1 to display in the Enter 2 to display in an
A
AB
right triangle. inverted right triangle.
ABCDE
BCDE
LH
ABC CDE
ABCD DE
ABCDE E
Question 2:
Write a menu driven program to generate the uppercase letters from Z to A and lowercase
letters from a to z as per the user’s choice. Enter 1 to display uppercase letters from Z to
A and Enter 2 to display lowercase letters from a to z.
Question 3:
Write a class to accept a String, and print the String with the uppercase and lowercase
characters reversed, but all the other characters should remain the same as before.
SAMPLE INPUT: WelCoMe_2025
SAMPLE OUTPUT: wELcOmE_2025
Question 4:
Define a class to declare an array to accept and store 10 words. Display only those words
which begin with the letter ‘A’ or ‘a’ and also end with the letter ‘A’ or ‘a’.
Question 5:
Define a class to accept 2 strings of the same length and form a new word in such a way
that the first character of the first word is followed by the first character of the second
word and so on.
Input String 1 - BALL Input string 2 - WORD Output : BWAOLRLD
Page 1 of 3
Assignment No 19:
Question 1: Write a program in Java to accept a String and convert the same to
uppercase, create and display the new string by replacing each vowel by the immediate
next character and every consonant by the previous character. The other characters remain
the same.
Sample Input: #IMAGINATION@2025
Sample output: #JLBFJMBSJPM@2025
Question 2: Write a class to accept a gmail id and check for its validity.
A gmail id is valid only if it has:
➔@
➔ . (dot)
➔ gmail
➔ com
Example : [email protected] is a valid gmail id
Question 3: Define a class to accept a string, convert it into lowercase and check whether
the string is a palindrome or not. A palindrome is a word which reads the same backward
S
as forward. Example: madam, racecar etc.
Assignment No 20:
Question 1: Design a class overloading and a function display( ) as follows:
1. void display(String str, int p) with one String argument and one integer argument. It
displays all the uppercase characters if 'p' is 1 (one) otherwise, it displays all the
LH
lowercase characters.
2. void display(String str, char chr) with one String argument and one character
argument. It displays all the vowels if chr is 'v' otherwise, it displays all the other
alphabets.
Question 2: Design a class to overload a function compare( ) as follows:
1. void compare(int, int) — to compare two integers values and print the greater of the
two integers.
2. void compare(char, char) — to compare the numeric value of two characters and
print with the higher numeric value.
3. void compare(String, String) — to compare the length of the two strings and print
the longer of the two.
Question 3: Design a class to overload the function display(.....) as follows:
1. void display(String str, char ch) — checks whether the word str contains the letter
ch at the beginning as well as at the end or not. If present, print 'Special Word'
otherwise print 'No special word'.
2. void display(String str1, String str2) — checks and prints whether both the words
are equal or not.
3. void display(String str, int n) — prints the character present at nth position in the
word str.
Page 2 of 3