Professional Documents
Culture Documents
Vidyaranyapura, Bangalore-97
Grade X 2019-20
Computer Applications
Assignment-3
Question 1.
Write a program that reads the following list of countries and their respective cities in two separate one- dimensional arrays.
The program should accept the name of a country in the list as an input and give the name of the corresponding city as
output. The program should be designed to give an error message when a city is asked for a country whose name is not
given in the list. To stop the program ‘XXX’ is to be entered as input.
Country City
Germany Berlin
Japan Tokyo
South Africa Pretoria
Australia Perth
Question 2.
Write a program to accept a character array containing alphabets. Shift all the vowels in one array and all the consonants in
another array. Print the elements of both the arrays.
Question 3.
Write a program to accept marks in computer application of 200 students. Print the frequency of each mark from 85 to 100.
Question 4.
Admissions are conducted in Management Institute as per following criteria:
Interview marks, written test marks and group discussion.
Marks are given out of 50 each and are added and then a merit list is prepared from maximum to minimum marks. Write a
program to prepare a merits list {containing names of 200 candidates (use bubble sort)}
Question 5.
Create a menu driven program in Java to perform the following operation on two matrices of dimension 3 x 3:
(i) Sum of two matrices
(ii) A count of odd numbers in the two matrices.
Question 6.
Write a program to store names in a double dimensional string array of size m X n. Print all the words whose length is more
than five along with their locations.
Question 7.
Accept a double dimensional array as a square matrix; print the sum of left diagonal elements and the sum of the right
diagonal elements.
Question 8.
Write a program to accept a string and print all the vowel pairs present in the string along with total number of pairs.
Sample Input: God is great.
Sample Output: e a.
Total number of vowels pairs = 1
Question 9.
Write a program using a method palin( ), to check whether a string is a palindrome or not. Palindrome is a string that reads
the same from left to right and vice versa.
Example: MADAM, ARORA, ABBA, etc.
Question 10.
Define a class Primes as follows:
Class Primes.
Data members/instance variable int n.
Methods
(i) Primes(int n) -to initialize n.
(ii) boolean isPrime( ) -returns true if n is a prime number.
(iii) boolean isPerfect( ) -returns true if n is a perfect number otherwise returns false.
Question 11.
Define a class ReverseCase with the following methods:
void change_to_Upper(String s) – changes only lowercase letters to UpperCase.
void change_to_lower(String s) – changes only upper case letter to lowerCase.
void change_case(string s) - changes lowercase letters to Uppercase and viceversa.
Write a program to create an object and call the above methods.
Question 12.
Write overloaded methods triangle ( ) to print the following patterns:
Void triangle(int n) = If n is 5, prints the triangle as:
*
* *
* * *
* * * *
* * * * *
Void triangle(int n,char c) – if n is 4 and c is ‘# ‘, print the following triangle :
#
# # #
# # # # #
# # # # # # #
Question 14.
You can encode or decode a sting in many ways. One of the simplest ways to replace each letter by a fixed distance ahead or
behind in the alphabet, where the alphabet is assumed to wrap around (i.e. : ‘A’ follows ‘Z’)
Sample Input: Given string ”COMPUTER” and encode=3, means each character moves three character ahead. Thus, new
string FRPSXWHU.
Question 15.
Write a program to remove duplicate characters from the string and print.
Sample input: MESKKPS Input: Application
Sample output: MESKPS. Output: Aplicton.