ICSE 2025-2026
Computer Application Assignment
Functions and Constructors
27 Write a java method ‘result’ that takes the marks in three subjects: eng, maths
and comp as parameters from the main. The method returns the percentage of
the student assuming that maximum marks of each subject is 100.
Define the main method for calling the ‘result’ method.
28 Design a class to overload a function num_calc( ) as follows:
a) void num_calc (int num, char ch) with one integer argument and one
character argument, computes the square of integer argument if choice
ch is ’s’ otherwise finds its cube.
b) void num_calc(int a, int b, char ch) with two integer arguments and one
character argument. It computes the product of integer arguments if ch
is ‘p’ else adds the integers.
c) void num_calc(String s1, String s2) with two string arguments, which prints
whether then strings are equal or not.
29 Design a class name ShowRoom with the following description:
Instance variables/ Data members :
String name – To store the name of the customer
int mobno – To store the mobile number of the customer
double cost – To store the cost of the items purchased
double dis – To store the discount amount
double amount – To store the amount to be paid after discount
Member methods: –
ShowRoom() – default constructor to initialize data members
void input() – To input customer name, mobile number, cost
void calculate() – To calculate discount on the cost of purchased items, based on
following criteria:
Cost Discount (in
percentage)
Less than or equal to ₹ 1000 5%
More than ₹ 1000 and less than or equal 10 %
to ₹ 2000
More than ₹ 2000 and less than or equal 15 %
to ₹ 3500
More than ₹ 3500 20 %
void display() – To display customer name, mobile number, amount to be paid
after discount
Write a main method to create an object of the class and call the above member
methods.
30 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.
Write a main method to create an object of the class and call the above member
methods.