23 24 Summary Notes Programs
23 24 Summary Notes Programs
IX. Mention the memory capacity of the following in terms of bits as well as bytes:-
1. 780
2. 12.4F
3. false
4. "Class X I.C.S.E 2022-23"
5. int a[]=new int[100];
6. char b[]=new char[10];
Also learn the theory of all the topics covering the entire syllabus (Summary points
with examples wherever required), inbuilt methods, keywords, syntax of all the
concepts.
PROGRAMS
I. Based on Data Members and Member functions:-
1. Define a class with the following specifications:-
Class Name:- Tax
Member variables:-
String name – stores the customer’s name
int a – stores the water consumption in gallons
int rate – stores the tax rate
Member methods:-
(i) Tax () – default constructor to initialize the data members with default values.
(ii) void input () – accept details for name and water consumption in gallons.
(iii) void compute () – find the tax rate based on the following criteria:
Water consumed (in Gallons) Tax Rate in `
More than 45 but 75 or less `475
More than 75 but 125 or less `750
More than 125 but 200 or less `1225
More than 200 but 350 or less `1650
More than 350 `2000
(iv) void display () – print the customer’s name, water consumption and the tax
rate. void main() – to create an object and call the above member methods.
2. Define a class with the following specifications:-
Class Name:- Bank
Member variables:-
double p – stores the principal amount
double n – stores the time period in years
double r – stores the rate of interest
double a – stores the amount
Member methods:-
(i) void accept () – input values for p and n
(ii) void calculate () – calculate the amount based on the following conditions:-
Time in (Years) Rate %
Upto ½ 9
> ½ <=1 10
>1<=3 11
>3 12
𝑟 𝑛
𝑎 = 𝑝 (1 + )
100
(iii) void display () – display the details in the given format.
Principal Time Rate Amount
xxx xxx xxx xxx
void main() – to create an object and call the above member methods.
3. Define a class with the following specifications:-
Class Name:- Taxi
Member variables:-
String n – stores the customer’s name
int km – stores the distance travelled in kilometres
int bill – stores the amount to be paid.
Member methods:-
(i) default constructor to initialize the data members with default values.
(ii) parameterized constructor to initialize the data members n and km.
(iii) void find () – calculate the bill amount to be paid based on:-
Distance (in Kms) Amount in `
First 5 kms `250 [fixed]
Next 5 Kms `100 per Km
More than 10 Kms `150 per Km
(iv) void print () – display the details.
void main() – to create an object and call the above member methods.
4. Define a class with the following specifications:-
Class Name:- Conversion
Member variables:-
double f – stores the temperature as Fahrenheit value
double c – stores the centigrade value
int m – stores the number of metres
int cm – stores the number of centimetres
int ft – stores the value as number of feet
int in – stores the value as number of inches
Member methods:-
(i) void get_data () – accept values for f, m and ft
Fahrenheit to centigrade 𝑐 = (𝑓 −
(ii) void convert () – convert the following:-
5
32) × 9
Metres to centimetres [1m = 100cm]
Feet to inches [1feet = 12 inches]
(iii) void output () – display the values in centigrade, centimetres and inches
void main() – to create an object and call the above member methods.
5. Define a class with the following specifications:-
Class Name:- Employee
Member variables:-
String name – stores the employee name
basic – stores the basic pay
da – stores the dearness allowance
sa – stores the special allowance
gs – stores the gross salary
[Declare the variables using appropriate datatypes]
Member methods:-
(i) void accept () – accept employee’s name and the basic pay
(ii) void compute () – calculate da, sa and gs based on
Basic Dearness Allowance (DA) Special Allowance (SA)
Up to `10,000 15% 5%
`10,001 – `20,000 20% 8%
`20,001 – `30,000 25% 10%
`30,001 and above 30% 12%
Gross salary = Basic + Dearness Allowance + Special Allowance
(iii) void display () – display the details.
void main() – to create an object and call the above member methods.
II. Based on Method Overloading:-
1. Define a class to overload the method print () as follows:-
(i) void print (int n) – prints all the factors of n, excluding itself.
(ii) boolean print (int x, int y) – returns true, if square of x is equal to y, otherwise returns
false.
(iii) void print () – display the following pattern
ABCDE
CDEF
EFG
GH
I
2. Define a class to overload the method display () as follows:-
(i) void display () – display the given pattern by initializing the word "FRAME"
F
FR
FRA
FRAM
FRAME
(ii) int display (int n) – returns the sum of the first and the last digit of n.
Example: If n is 183, sum=4 (1+3)
(iii) void display (double income) – Calculate and display the tax as 5% on the income if
income is beyond `50,000, otherwise display the message as "No tax".
3. Define a class to overload the method perform () as follows:-
(i) void perform () – display the following
pattern 1
34
567
78910
(ii) boolean perform (int n) – to check whether the input number is abundant number or not.
An Abundant number is a number for which the sum of its proper factors is greater than
the number itself.
Example:
Consider the number 12.
Factors of 12 = 1, 2, 3, 4, 6 Sum of factors = 1 + 2 + 3 + 4 + 6 = 16
As 16 > 12 so 12 is an Abundant number.
(iii) void perform (int a, char ch) – which accepts one integer and one character argument
finds and displays the square root of a if ch is 's' or 'S' otherwise finds and displays
the cube root of a.
4. Define a class to overload the method output () as follows:-
(i) void output () – display the following pattern
98765
8765
765
65
5
(ii) void output (int n) – to check whether the input number is the number n is pure EVEN
number or not. A number is called pure EVEN if all the digits in a
number n is divisible by 2, otherwise display appropriate error
message.
For Example:
Input value for n: 2468
Output: Pure EVEN
(iii) void output (int a, int b, int c) – a, b and c are the 3 sides of a triangle, check and display
the message "triangle is possible" if sum of any 2 sides
is greater than the 3rd side, otherwise display the
message "triangle not possible".
5. Define a class to overload the method execute () as follows:-
(i) void execute () – display the following pattern
*@*@*@*@*@
*@*@*@*@*@
*@*@*@*@*@
(ii) void execute (int n) – to check whether the input number is a neon number or not. A
number is called neon, if the sum of digits of its squared value
is equal to the input number n.
Example: 9 is a neon number, because sum of digits of its square
92=81(8+1) is equal to the input number.
(iii) void execute (char c1, char c2) - Convert the characters to uppercase if both c1 and c2
are in lowercase and vice-versa, otherwise display the
characters in two different lines.
III. Based on String methods:-
1. Define a class to accept a string and display the count of uppercase alphabets,
lowercase alphabets, uppercase vowels, lowercase vowels, uppercase consonants
and lowercase consonants.
Example:
Input String: ICSE Year 2023 Examinations
Output: Count of uppercase alphabets=6 Count of lowercase vowels=7
Count of lowercase alphabets=14 Count of uppercase
consonants=3 Count of uppercase vowels=3 Count of lowercase
consonants=7
2. Define a class to accept a string and convert to uppercase and display the new string by
replacing each vowel by immediate next character and every consonant by the
previous character. The other characters remain the same.
Example:
Input String: IMAGINATION
New String : JLBFJMBSJPM
3. Define a class to accept two strings and convert both the strings to lowercase and check
whether both the strings have even number of characters, If so, then reverse both the
strings and frame a new string by joining the first reversed string followed by the second
reversed string.
Example:
Input string1: exam
Input string2: exit
Output: maxetixe
4. Define a class to accept a string and a character and convert both the string and the
character to uppercase and find and display how many times the character is repeated in
the string. If the count is odd, then display all the characters at the ODD index
positions.
Example:
Input String: Good Food Output1: Frequency of o is 4
Input character: o Output2: Character at odd index: O,D,F,O
5. Define a class to accept a string and display the absolute difference between characters.
Example:
Input String: Timer
Output:
Absolute difference between T and i is 21
Absolute difference between i and m is 4
Absolute difference between m and e is 8
Absolute difference between e and r is 13
IV. Based on Arrays – calculation based:-
1. Define a class to accept 10 integers in an array. Display all the negative numbers followed
by the positive numbers without changing the order of the numbers.
2. Define a class to accept 20 integers in an array and display the list of integers that are
perfect squares.
3. Define a class to accept 20 characters in an array and count the number of letters, digits
and special characters.
4. Define a class to accept and store N students’ marks out of 100 in a subject in an array
and display the subject average, highest and the least score.
5. Define a class to accept 20 integer values in an array and find and display the sum of first
10 values, product of last 10 values, first value, middle value and the last value.
V. Based on Arrays – Searching concept:-
1. Define a class to accept and store N product names in an array and search for a product
input by the user and display the position if it is found in the array, otherwise display
appropriate error message using Linear search technique. Also display all the products
that begins with a vowel.
2. Define a class to accept 10 cricketer’s names and their corresponding runs scored in two
different single subscripted variables. Search for a cricketer’s name and display the
corresponding runs along with the cricketer’s name if found in the array, otherwise display
the message "data not found" using Linear search technique.
3. Define a class to search for a number from the list of numbers given below and display the
message "Search Successful" if found in the array, otherwise display "Search
unsuccessful" using binary search technique. 100, 87, 76, 70, 67, 63, 62, 51, 32, 23, 13, 3
4. Define a class to accept and store 20 characters in an array and search for a character input
by the user and display the position if the character is present in the array, otherwise
display appropriate error message using binary search technique.
(Assume the characters in the array are in alphabetical order)
VI. Based on Arrays – Sorting concept:-
1. Define a class to accept 20 float datatype values in array and arrange them in
ascending order using bubble sort technique. Display the unsorted and the sorted array.
2. Define a class to accept 10 book names in an array and arrange the book names in reverse
alphabetical order using Bubble sort technique. Display the unsorted and the sorted array.
3. Define a class to accept 10 students’ names and their corresponding percentage marks in
two different arrays and arrange the percentage marks in ascending order along with the
names using bubble sort technique. Display the sorted arrays as
Name Percentage
…. …….
4. Define a class to accept 10 characters in an array and arrange the characters in ascending
order using bubble sort technique. Display the unsorted and the sorted array.
VII. Based on Menu driven using switch:-
1. Using switch statement, write a menu driven program to
1. Print Series 1,2,9,28,65,.........................n terms
2. Sum Series 𝑠𝑢𝑚 1
19
5 +⋯…………−
3− 7 + − 20
= 2 6
4 8
An appropriate error message should be displayed for incorrect choice.
2. Using switch statement, write a menu driven program to