Class 12 UNIT TEST 1 Computer Science
Class 12 UNIT TEST 1 Computer Science
COMPUTER SCIENCE
UNIT TEST 1 FM: 30
CLASS XII
Questions1 : Design a class Coding to perform some string related operations on a word
containing alphabets only.
Example Input: Java
Output : Original word: Java
J=74
a=97
v=118
a=97
Lowest ASCII code: 74
Highest ASCII code: 118
Some of the members of the class are given below.
Class name: Coding
Data members/Instance variables :
wrd : to store the word
len : to store the length of the word
Methods/ Member functions :
Coding() : constructor to initialize the data members
void accept () : to accept the word
void find () : to display all the characters of wrd along with their ASCII code . Also display the
lowest and the highest ASCII code in wrd.
void show(): to display the original word and all the characters of the wrd along with their
ASCII code . Also find the lowest and the highest ASCII code in wrd by invoking the function
find().
Questions 2: Design a class findfreq to accept a sentence and to perform some string
related operations on the sentence.
Example Input: APPLE LIVE
Output :
CHARACTERS FREQUENCY
A 1
E 2
I 1
L 2
P 2
V 1
Some of the members of the class are given below.
Class name: findfreq
Data members/Instance variables :
int freq : to store the frequency of each Characters
String sen : to store the sentence from the user
Methods/ Member functions :
findfreq() : constructor to initialize the data members
void getsen() : to accept the sentence
void findit ( ) : to find the frequency of each characters present .
void print(): to display the characters present in the sentence along with the frequency of
each characters as example given above.
Questions 3: Design a class Mixmax to accept two words and to perform some string
related operations on both the words.
Example Input:
WORD 1 : TOP
WORD 2: CLASS
Output : TCOLPASS