Programs For Icse STD 10

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

PROGRAMS FOR ICSE STD 10-2024

Q1. Define a class called with the following specifications:

Class name: Eshop

Member variables:
String name: name of the item purchased
double price: Price of the item purchased

Member methods:
void accept(): Accept the name and the price of the item using the methods of Scanner class.
void calculate(): To calculate the net amount to be paid by a customer, based on the following criteria:

Price Discount

1000 – 25000 5.0%

25001 – 57000 7.5 %

57001 –
10.0%
100000

More than
15.0 %
100000

void display(): To display the name of the item and the net amount to be paid.

Write the main method to create an object and call the above methods.

Q2. Define a class to overload the function print as follows:

void print() - to print the following format

1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
void print(int n) - To check whether the number is a lead number. A lead number is the one whose sum of
even digits are equal to sum of odd digits.

e.g. 3669
odd digits sum = 3 + 9 = 12
even digits sum = 6 + 6 = 12
3669 is a lead number.

Q3. Define a class to declare a character array of size ten. Accept the characters into the array and display
the characters with highest and lowest ASCII (American Standard Code for Information Interchange)
value.
EXAMPLE :
INPUT:
'R', 'z', 'q', 'A', 'N', 'p', 'm', 'U', 'Q', 'F'

OUTPUT :
Character with highest ASCII value = z
Character with lowest ASCII value = A

Q4. Define a class to accept a string, and print the characters with the uppercase and lowercase reversed,
but all the other characters should remain the same as before.

EXAMPLE:
INPUT : WelCoMe_2022
OUTPUT : wELcOmE_2022

Q5. Define a class to accept two strings of 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.
Example :
Input string 1 – BALL
Input string 2 – WORD
OUTPUT : BWAOLRLD

Q6. Using the switch-case statement, write a menu driven program to do the following:

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

Character Unicode

A 65

B 66

. .

. .

. .

Z 90

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

1
12
123
1234
12345

Q7Write 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 x 4
20 = 4 x 5
42 = 6 x 7
Q8Write a program in Java to accept a string in lower case and change the first letter of every word to
upper case. Display the new string.

Sample input: we are in cyber world


Sample output: We Are In Cyber World

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

1.double volume (double R) – with radius (R) as an argument, returns the volume of sphere using the
formula.
V = 4/3 x 22/7 x R3

2.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 x R2 x H

3.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=LxBxH
Q9. Write a menu driven program to display the pattern as per user’s choice.

Pattern 1

ABCDE
ABCD
ABC
AB
A

Pattern 2

B
LL
UUU
EEEE

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

Q10. 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 of its digits equals the product of its 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

You might also like