18 To 20 - X Assignments
18 To 20 - X Assignments
: ____________________
Roll No. : _______ Date:______________ Term : II Assignment No: 18 to 20
Subject: Computer Applications Topic: Assignment Questions
Assignment No 18:
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
right triangle. inverted right triangle.
Question 2:
A
AB
ABC
ABCD
ABCDE
S ABCDE
BCDE
CDE
DE
E
LH
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_2022
SAMPLE OUTPUT: wELcOmE_2022
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
Assignment No 19:
Question 1: Write a program in Java to accept a String in upper case and replace
all the vowels present in the String with Asterisk (*) sign.
Sample Input: TATA STEEL IS IN JAMSHEDPUR
Sample output: T*T* ST**L *S *N J*MSH*DP*R
Question 2: Write a program to accept full name and display the initials along with
the surname.
SAMPLE INPUT: Mohandas Karamchand Gandhi
SAMPLE OUTPUT: M. K. Gandhi
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 as forward. Example: madam, racecar etc.
Assignment No 20:
Question 1: Design a class overloading and a function display( ) as follows:
S
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 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
LH
other alphabets.
Page 2