# ICSE Solved Questions

## Question 4

Design a class name ShowRoom with the following description:
Instance variables/data members:
String name: to store the name of the customer.
long mobno: to store customer’s mobile number.
double cost: to store the cost of the item purchased.
double dis: to store the discount amount.
double amount: to store the amount to be paid after discount.
Methods:

ShowRoom(): default constructor to initialize the data members
void input(): to input customer name, mobile number, cost
void calculate(): to calculate the discount on the cost of purchased items, based on the following criteria

```				```
Cost	                                                  Discount(In percentage)
Less than or equal to ₹ 10000                                   5%
More than ₹ 10000 and less than or equal to ₹ 20000             10%
More than ₹ 20000 and less than or equal to ₹ 35000	            15%
More than ₹ 35000	                                            20%

```
```

1) void display()- To display customer, mobile number, amount to be paid after discount.
Write a main() method to create an object of the class and call the above methods.

## Question 5

Use the switch case statement, write a menu driven program to do the following:

(a) To generate and print letters from A to Z & their Unicode

```				```
Letter     unicode
A          65
B          66
C          67
-          -
-          -
-          -
Z          90
```
```

(b) Display the following pattern iteration (looping) statement:

```				```
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
```
```

## Question 6

Write a program to input 15 integer elements in an array and sort them in ascending order using the bubble sort technique.

## Question 7

Design a class to overload a function series() as follows:

(i) void series(int x, int n) – To display the sum of the series given below:

x¹+x²+x³+. . . . .x^n terms

(ii)void series(int p) – To display the following series
0, 7, 26, 63. . . . .p terms

(iii) void series() – To display the sum of the series given below:
1/2+1/3+1/4+. . . . . .1/10

## Question 8

Write a program to input a sentence and convert it into uppercase and count and display the total no. of words starting with a letter ‘A’.

```				```
Example:
Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY ARE EVER CHANGING
Sample Output: Total number of word Starting with letter ‘A’= 4
```
```

## Question 9

A tech number has a even number of digits if the number is split in two equal halves , then the square of sum of these two halves is equal to the number itself. Write a program to generate and print all 4 digit tech numbers:

```				```
Example:
Consider the number 3025
Square of sum of the halves of 3025
= (30 + 25)²
= (55)²
3025 is a tech number
```
```

## Question 4

Design a class RailwayTicket with the following description:
Instance variables/data members:
String name: to store the name of the customer.
String coach: to store the type of coach customer wants to travel.
long mobno: to store customer’s mobile number.
int amt: to store basic amount of ticket.
int totalamt: to store the amount to be paid after updating the original amount.
Methods:
void accept(): to take input for name, coach, mobile number and amount.
void update(): to update the amount as per the coach selected. Extra amount to be added in the amount as follows:

```				```
Type of coaches          Amount
First_AC                  700
Second_AC                 500
Third_AC                  250
sleeper                   None
```
```

void display(): To display all details of a customer such as name, coach, total amount and mobile number.
Write a main() method to create an object of the class and call the above methods.

## Question 5

Write a program to input a number and check and print whether it is a Pronic number or not. Pronic number is the number which is the product of two consecutive integers.
Examples:
12 = 3 × 4
20 = 4 × 5
42 = 6 × 7

## Question 6

Write a program in Java to accept a string in lowercase and change the first letter of every word to uppercase. Display the new string.

```				```
Sample INPUT: we are in cyber world
Sample OUTPUT: We Are In Cyber World
```
```

## Question 7

Design a class to overload a function volume() as follows:

(i) double volume(double r) – with radius ‘r’ as an argument, returns the volume of sphere using the formula:
v = 4 / 3 × 22 / 7 × r3

(ii)double volume(double h, double r) – with height ‘h’ and radius ‘r’ as the arguments, returns the volume of a cylinder using the formula:
v = 22 / 7 × r2 × h

(iii) double volume(double l, double b, double h) – with length ‘l’, breadth ‘b’ and height ‘h’ as the arguments, returns the volume of a cuboid using the formula:
v = l × b × h

## Question 8

Write a menu-driven program to display the pattern as per user’s choice:

Pattern 1

ABCDE

ABCD

ABC

AB

A

Pattern 2
B
L L
U U U
E E E

For an incorrect option, an appropriate error message should be displayed.

## Question 9

Write a program to accept name and total marks of N number of students in two single subscripts array name[] and totalmarks[].

Calculate and print:
(i) The average of the total marks obtained by N number of students.
[average = (sum of total marks of all the students) / N]
(ii) Deviation of each student’s total marks with the average.
[deviation = total marks of a student – average]

## Question 4

Define a class Electric Bill with the following specifications:

class: ElectricBill
Instance Variable/ data member:
String n – to store the name of the customer
int units – to store the number of units consumed
double bill – to store the amount to paid
Member methods:
Void accept() – to accept the name of the customer and number of units consumed
Void calculate() – to calculate the bill as per the following tariff :

```				```
Number of units — Rate per unit
First 100 units — Rs.2.00
Next 200 units — Rs.3.00
Above 300 units — Rs.5.00
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
```
```

Void print() – To print the details as follows :
Name of the customer ………
Number of units consumed ……
Bill amount …….
Write a main method to create an object of the class and call the above member methods.

## Question 5

Write a program to accept a number and check and display whether it is a spy number or not.

(A number is spy if the sum its digits equals the product of the digits.)

Example: consider the number 1124 , sum of the digits = 1 + 1 + 2 + 4 = 8 Product of the digits = 1 x 1 x 2 x 4=8

## Question 6

Using switch statement, write a menu driven program for the following:

i) To find and display the sum of the series given below:
S = x1 – x2 + x3 – x4 + x5 … – x20
(where x=2)

ii) To display the following series:
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.

## Question 7

Write a program to input integer elements into an array of size 20 and perform the following operations:
i) Display largest number from the array
ii) Display smallest number from the array
iii) Display sum of all the elements of the array

## Question 8

Design a class to overload a function check() as follows:
i) void check(String str, char ch) – to find and print the frequency of a character
in a string.
Example :
Input — Output
Str = “success” number of s present is=3
ch = ‘s’
ii) void check (String s1) – to display only the vowels from string s1 , after converting it to lower case.
Example :
Input: S1= “computer”

output: o u e

## Question 9

Write a program to input forty words in an array. Arrange these words in descending order of alphabets, using the selection sort technique. Print the sorted array.

## Question 4

Define a class named BookFair with the following description:

Instance variables/Data members:
String Bname – stores the name of the book.
double price – stores the price of the book.

Member Methods:
(i) BookFair() – Default constructor to initialize data members.
(ii) void Input() – To input and store the name and the price of the book.
(iii) void calculate() – To calculate the price after discount. Discount is calculated based on the following criteria.

```				```
PRICE DISCOUNT
Less than or equal to Rs 1000:  2% of price
More than Rs 1000 and less than or equal to Rs 3000:  10% of price
More than Rs 3000:  15% of price
```
```

(iv) void display() – To display the name and price of the book after discount.

Write a main method to create an object of the class and call the above member methods.

## Question 5

Using the switch statement, write a menu driven program for the following:

(i) To print the Floyd’s triangle [Given below]

1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

(ii) To display the following pattern

I
I C
I C S
I C S E

For an incorrect option, an appropriate error message should be displayed.

## Question 6

Special words are those words which starts and ends with the same letter.
Examples: EXISTENCE ,COMIC, WINDOW

Palindrome words are those words which read the same from left to right and vice-versa.
Example: MALAYALAM MADAM LEVEL ROTATOR CIVIC
All palindromes are special words, but all special words are not palindromes. Write a program to accept a word check and print whether the word is a palindrome or only special word.

## Question 7

Design a class to overload a function SumSeries() as follows:
(i) void SumSeries(int n, double x) – with one integer argument and one double argument to find and display the sum of the series given below:
s = (x/1) – (x/2) + (x/3) – (x/4) + (x/5) … to n terms

(ii) void SumSeries() – To find and display the sum of the following series:
s = 1 + (1 X 2) + (1 X 2 X 3) + … + (1 X 2 X 3 X 4 X … 20)

## Question 8

Write a program to accept a number and check and display whether it is a Niven number of not.

(Niven number is that number which is divisible by its sum of digits).

Example: Consider the number 126. Sum of its digits is 1 + 2 + 6 = 9 and 126 is divisible by 9.

## Question 9

Write a program to initialize the seven Wonders of the World along with their locations in two different arrays. Search for a name of the country input by the user. If found, display the name of the country along with its Wonder, otherwise display “Sorry Not Found!”
Seven wonders – CHICHEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations – MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example – Country Name: INDIA Output: INDIA – TAJMAHAL
Country Name: USA

## Question 4

Define a class ParkingLot with the following description:
Instance variables/data members:
int vno – To store the vehicle number
int hours – To store the number of hours the vehicle is parked in the parking lot
double bill – To store the bill amount
Member methods:
void input() – To input and store vno and hours
void calculate() – To compute the parking charge at the rate of Rs.3 for the first hour or part thereof, and Rs.1.50 for each additional hour or part thereof.
void display() – To display the detail
Write a main method to create an object of the class and call the above methods

## Question 5

Write two separate programs to generate the following patterns using iteration(loop) statements:
(a)

*
* #
* # *
* # * #
* # * # *

(b)
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5

## Question 6

Write a program in to input and store all roll numbers, names and marks in 3 subjects of n number of students in five single dimensional arrays and display the remark based on average marks as given below:

Average marks = total marks/3

AVERAGE MARKS REMARK
85 – 100: EXCELLENT
75 – 84 :DISTINCTION
60 – 74 :FIRST CLASS
40 – 59 :PASS
Less than 40: POOR

## Question 7

Design a class to overload a function Joystring() as follows:
(i) void Joystring(String s, char ch1, char ch2) with one string and two character arguments that replaces the character argument ch1 with the character argument ch2 in the given string s and prints the new string
Example:
Input value of s = “TECHNALAGY”
ch1 = ‘A’
ch2 = ‘O’
Output : “TECHNOLOGY”

(ii) void Joystring(String s) with one string argument that prints the position of the first space and the last space of the given String s.
Example:
Input value of = “Cloud computing means Internet based computing”
First Index : 5
Last Index : 36

(iii) void Joystring(String s1, String s2) with two string arguments that combines the two strings with a space between them and prints the resultant string
Example :
Input value of s1 = “COMMON WEALTH”
s2 = “GAMES”
Output : “COMMON WEALTH GAMES”
(use library functions)

## Question 8

Write a program to input twenty names in an array. Arrange these names in descending order of alphabets , using the bubble sort technique.

## Question 9

Use switch statement,write a menu driven program to:

(i) To find and display all the factors of a number input by the user (including 1 and excluding number itself.)
Example :
Sample Input : n = 15.
Sample Output : 1, 3, 5

(ii) To find and display the factorial of a number input by the user. The factorial of a non-negative integer n ,denoted by n!,is the product of all integers less than or equal to n.
Example :
Sample Input : n = 5
Sample Output : 120.

For an incorrect choice, an appropriate error message should be displayed.

## Question 4

Define a class named movieMagic with the following description:

Instance variables/data members:

int year – to store the year of release of a movie
String title – to store the title of the movie.
float rating – to store the popularity rating of the movie. (minimum rating = 0.0 and maximum rating = 5.0)

Member Methods:
(i) movieMagic() Default constructor to initialize numeric data members to 0 and String data member to “”.
(ii) void accept() To input and store year, title and rating.
(iii) void display() To display the title of a movie and a message based on the rating as per the table below. RATING MESSAGE TO BE DISPLAYED

0.0 to 2.0: Flop

2.1 to 3.4: Semi-hit

3.5 to 4.5 :Hit

4.6 to 5.0: Super Hit

Write a main method to create an object of the class and call the above member methods.

## Question 5

A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number.

Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits= 14 + 45 = 59

Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, output the message “Special 2-digit number” otherwise, output the message “Not a Special 2-digit number”.

## Question 6

Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and file extension separately as shown.

File name: flower
Extension: jpg

## Question 7

Design a class to overload a function area() as follows:

(i) double area(double a. double b, double e) with three double arguments, returns the area of a scalene triangle.

area = √(s(s – a)(s – b)(s – c))
where s = (a + b + c) / 2.

(ii) double area(int a, int b, int height) with three integer arguments, returns the area of a trapezium

area = 1/2 × height × (a + b)

(iii) double area(double diagonal1, double diagonal2) with two double arguments, returns the area of a rhombus

area = 1/2 × (diagonal1 × diagonal2)

## Question 8

Using the switch statement. write a menu driven program to calculate the maturity amount of a Bank Deposit.

The user is given the following options:
(i) Term Deposit
(ii) Recurring Deposit

For option (i) accept principal(P), rate of interest(r) and time period in years(n). Calculate and output the maturity amount(A) receivable using the Formula:

P(1+r/100)n

For option (ii) accept Monthly Installment (P), rate of interest(r) and time period in months (n). Calculate and output the maturity amount(A) receivable using the formula

P*n+(P*(n*(n+1))/2)*(r/100)*(1/12)

For an incorrect option, an appropriate error message should be displayed.

## Question 9

Write a program to accept the year of graduation from school as an integer value from the user. Using the Binary Search technique on the sorted array of integers given below, output the message ‘Record exists’ if the value input is located in the array. If not, output the message Record does not exist”.
(1982, 1987, 1993. 1996, 1999, 2003, 2006, 2007, 2009, 2010)

## Question 4

Define a class called FruitJuice with the following description:

Instance variables/data members:
int product_code – stores the product code number
String flavour – stores the flavour of the juice.(orange, apple, etc)
String pack_type – stores the type of packaging (tetra-pack, bottle etc)
int pack_size – stores package size (200ml, 400ml etc)
int product_price – stores the price of the product

Member Methods:
FruitJuice() – default constructor to initialize integer data members
to zero and string data members to “”.
void input() – to input and store the product code, flavour, pack type,
pack size and product price.
void discount() – to reduce the product price by 10.
void display() – to display the product code, flavor, pack type,
pack size and product price.

## Question 5

The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10-digit code. The ISBN is legal if:
1xdigit1 + 2xdigit2 + 3xdigit3 + 4xdigit4 + 5xdigit5 + 6xdigit6 + 7xdigit7 + 8xdigit8 + 9xdigit9 + 10xdigit10 is divisible by 11.
Example: For an ISBN 1401601499
Sum=1×1 + 2×4 + 3×0 + 4×1 + 5×6 + 6×0 + 7×1 + 8×4 + 9×9 + 10×9 = 253 which is divisible by 11.
Write a program to:
(i) input the ISBN code as a 10-digit integer.
(ii) If the ISBN is not a 10-digit integer, output the message “Illegal ISBN” and terminate the program.
(iii) If the number is 10-digit, extract the digits of the number and compute the sum as explained above.
If the sum is divisible by 11, output the message, “Legal ISBN”. If the sum is not divisible by 11, output the message, “Illegal ISBN”.

## Question 6

Write a program that encodes a word into Piglatin. To translate word into Piglatin word, convert the word into uppercase and then place the first vowel of the original word as the start of the new word along with the remaining alphabets. The alphabets present before the vowel being shifted towards the end followed by “AY”.
Sample Input(1): London Sample Output(1): ONDONLAY
Sample Input(2): Olympics Sample Output(2): OLYMPICSAY

## Question 7

Write a program to input 10 integer elements in an array and sort them
In descending order using bubble sort technique.

## Question 8

Design a class to overload a function series() as follows:
(i) double series(double n) with one double argument and returns the sum of the series.
sum = 1/1 + 1/2 + 1/3 + ….. 1/n
(ii) double series(double a, double n) with two double arguments and returns the sum of the series.
sum = 1/a2 + 4/a5 + 7/a8 + 10/a11 ….. to n terms

## Question 9

Using the switch statement, write a menu driven program:
(i) To check and display whether a number input by the user is
a composite number or not (A number is said to be a composite, if it
has one or more then one factors excluding 1 and the number itself).
Example: 4, 6, 8, 9…
(ii) To find the smallest digit of an integer that is input:
Sample input: 6524
Sample output: Smallest digit is 2
For an incorrect choice, an appropriate error message should be displayed.

## Question 4

Define a class called Library with the following description:
Instance variables/data members:
Int acc_num – stores the accession number of the book

String title – stores the title of the book

String author – stores the  name of the author

Member Methods:
(i) void input() – To input and store the accession number, title and author.

(ii)void compute() – To accept the number of days late, calculate and display the fine charged at the rate of Rs.2 per day.

(iii) void display() To display the details in the following format: Accession Number Title Author.

Write a main method to create an object of the class and call the above member methods.

## Question 5

Given below is a hypothetical table showing rates of Income Tax for male citizens below the age of 65 years:

```				```
Taxable Income (TI)           Income Tax
< 1,60,000                       Nil
>1,60,000 and <= 5,00,000     ( TI – 1,60,000 ) * 10%
> 5,00,000 and <= 8,00,000    [(TI – 5,00,000 ) *20%] + 34,000
> 8,00,000                    [(TI – 8,00,000 ) *30% ] + 94,000

```
```

Write a program to input the age, gender (male or female) and Taxable Income of a person.If the age is more than 65 years or the gender is female, display “wrong category”. If the age is less than or equal to 65 years and the gender is male, compute and display the Income Tax payable as per the table given above.

## Question 6

Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences that exist in the string.

```				```
Sample Input: “SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLE"
Sample Output: 4
```
```

## Question 7

Design a class to overload a function polygon() as follows:
(i) void polygon(int n, char ch) : with one integer argument and one character type argument that draws a filled square of side n using the character stored in ch.
(ii) void polygon(int x, int y) : with two integer arguments that draws a filled rectangle of length x and breadth y, using the symbol ‘@’
(iii)void polygon( ) : with no argument that draws a filled triangle shown below.

```				```
Example:
(i) Input value of n=2, ch=’O’
Output:
O O
O O
(ii) Input value of x=2, y=5
Output:
@ @ @ @ @
@ @ @ @ @
(iii) Output:
*
* *
* * *
```
```

## Question 8

Using the switch statement, write a menu driven program to:
(i) Generate and display the first 10 terms of the Fibonacci series 0,1,1,2,3,5….The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.
(ii)Find the sum of the digits of an integer that is input.
Sample Input: 15390
Sample Output: Sum of the digits=18
For an incorrect choice, an appropriate error message should be displayed

## Question 9

Write a program to accept the names of 10 cities in a single dimension string array and their STD (Subscribers Trunk Dialing) codes in another single dimension integer array. Search for a name of a city input by the user in the list. If found, display “Search Successful” and print the name of the city along with its STD code, or else display the message “Search Unsuccessful, No such city in the list’.

## Question 4

Define a class called mobike with the following description:

Instance variables/data members:

int bno – to store the bike’s number

int phno – to store the phone number of the customer

String name – to store the name of the customer

int days – to store the number of days the bike is taken on rent

int charge – to calculate and store the rental charge

Member methods:

void input( ) – to input and store the detail of the customer.

void compute( ) – to compute the rental charge
The rent for a mobike is charged on the following basis.

First five days :Rs 500 per day

Next five days: Rs 400 per day

Rest of the days: Rs 200 per day

void display ( ) – to display the details in the following format:

Bike No.| PhoneNo.| No. of days |Charge

## Question 5

Write a program to input and sort the weight of ten people. Sort and display them in descending order using the selection sort technique

## Question 6

Write a program to input and sort the weight of ten people. Sort and display them in descending order using the selection sort technique

```				```
Sample Input: “SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLE"
Sample Output: 4
```
```

## Question 7

Write a program to accept a word and convert it into lowercase if it is in uppercase, and display the new word by replacing only the vowels with the character following it.

```				```
Example:
Sample Input : computer
Sample Output : cpmpvtfr
```
```

## Question 8

Design a class to overload a function compare ( ) as follows:

(a) void compare (int, int) – to compare two integer values and print the greater of the two integers.

(b) void compare (char, char) – to compare the numeric value of two character with higher numeric value

(c) void compare (String, String) – to compare the length of the two strings and print the longer of the two.

## Question 9

Write a menu driven program to perform the following . (Use switch-case statement)

(a) To print the series 0, 3, 8, 15, 24 ……. n terms (value of ‘n’ is to be an input by the user).

(b) To find the sum of the series given below:
S = 1/2+ 3/4 + 5/6 + 7/8 … 19/20

## Question 4

Write a program to perform binary search on a list of integers given below, to search for an element input by the user. If it is found display the element along with its position, otherwise display the message “Search element not found”.
5,7,9,11,15,20,30,45,89,97

## Question 5

Define a class Student described as below:
Data members/instance variables : name,age,m1,m2,m3 (marks in 3 subjects), maximum, average
Member methods :

(i) A parameterized constructor to initialize the data members.

(ii) To accept the details of a student.

(iii) To compute the average and the maximum out of three marks.

(iv) To display the name, age, marks in three subjects, maximum and average.
Write a main method to create an object of a class and call the above member methods.

## Question 6

Shasha Travels Pvt. Ltd. gives the following discount to its customers:
Ticket amount Discount
Above Rs 70000 – 18%
Rs 55001 to Rs 70000 – 16%
Rs 35001 to Rs 55000 – 12%
Rs 25001 to Rs 35000 – 10%
less than Rs 25001 – 2%

Write a program to input the name and ticket amount for the customer and calculate the discount amount and net amount to be paid. Display the output in  the following format for each customer :

(Assume that there are 15 customers, first customer is given the serial no (SlNo.) 1, next customer 2 … and so on.

```				```
SL.NO. Name Ticket charges Discount Net amount 1
-       -     -              -        -
```
```

(Assume that there are 15 customers, first customer is given the serial no (SlNo.) 1, next customer 2 … and so on.

## Question 7

Write a menu driven program to accept a number and check and display whether it is a Prime Number or not OR an Automorphic Number or not. (Use switch-case statement).

(a) Prime number : A number is said to be a prime number if it is divisible only by 1 and itself and not by any other number. Example : 3,5,7,11,13 etc.

(b) Automorphic number : An automorphic number is the number which is contained in the last digit(s) of its square.
Example: 25 is an automorphic number as its square is 625 and 25 is present as the last two digits.

## Question 8

Write a program to store 6 element in an array P, and 4 elements in an array Q and produce a third array R, containing all elements of array P and Q. Display the resultant array .

## Question 9

Write a program to input a string in uppercase and print the frequency of each character.

## Coding Store

Sale ### Mastering String

50
Sale 150
Sale 200
Sale ### Mastering Recursion

50
Sale ### Mastering Numbers

50
Sale ### Mastering Matrix

50
Sale ### Mastering Array

50
Sale ### ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)

50
Sale 50