Final G10 ICSE Assignments 2022 23
Final G10 ICSE Assignments 2022 23
2 Write a program to input the values and calculate the value of the 2
integer X based on the following expression:
X= a+ba+³√c+5
Function 16 Write a java method ‘result’ that takes the marks in three 17
s and subjects: eng, maths and comp as parameters from the main.
Construc The method returns the percentage of the student assuming that
tors maximum marks of each subject is 100.
Define the main method for calling the ‘result’ method.
20
Define a class named Fruit Juice with the following description:
Instance variables / data members :
int product_code — stores the product code number
String flavour — stores the flavour of the juice (E.g. orange,
apple, etc.)
String pack_type — stores the type of packaging (E.g. tetra-
pack, PET bottle, etc.)
int pack_size — stores package size (E.g. 200 ml, 400 ml, etc.)
int product_price — stores the price of the product
Member methods :
(i) FruitJuice() — Default constructor to initialize integer data
members to 0 and String data members to.
(ii) void input( ) — To input and store the product code, flavour,
pack type, pack size and product price.
(iii) void discount( ) — To reduce the product price by 10.
(iv) void display() — To display the product code, flavour, pack
type, pack size and product price.
Strings
21
Write a main method to create an object of the class and call the
above member methods.
22
Write a program to input a word from the user and remove the
consecutive repeated characters by replacing the sequence of
repeated characters by its single occurrence.
36 Example 1:
INPUT – Jaaavvvvvvvvaaaaaaaaaaa
OUTPUT – Java
Example 2:
INPUT – Heeeiiiissggoiinggg
OUTPUT – Heisgoing
Arrays 37 Write a program to declare an integer array of size 5. Initialize all
its elements to zero. Accept the values of the array elements
from the user and then display it.