Page 495 - CA_Blue( J )_Class10
P. 495
SECTION B (60 Marks)
Answer any four questions from this Section
The answers in this section should consist of the programs in either BlueJ environment or
any program environment with java as the base.
Each program should be written using variable description/mnemonic codes so that the logic of the program is clearly depicted.
Flowcharts and algorithms are not required,
3. Define a class with the following specifications [15]
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:
void accept() – input values for p and n using Scanner class methods only.
void calculate() – calculate the amount based on the following conditions:
Time in (Years) Rate %
Upto ½ 9
> ½ to 1 year 10
> 1 to 3 years 11
> 3 years 12
r n
a = p 1 +
100
void display() – display the details in the given format.
Principal Time Rate Amount
xxx xxx xxx xxx
Write the main method to create an object and call the above methods. [Understanding/Application]
Ans. importjava.util.*;
class bank
{
double p,n,r,a;
Scanner ob = new Scanner(System.in);
void accept()
{
System.out.println("Enter principal");
p=ob.nextDouble();
System.out.println("Enter number of years");
n=ob.nextDouble();
}
void calculate()
{
if(n<=0.5)
r=9;
else
if(n>0.5&&n>=l)
r=10;
else
if(r> l&&n<=3)
r=ll;
a=p*Math.pow(l +r/100,n);
}
void display()
{
493
ICSE SPECIMEN QUESTION PAPER (2025) 493

