Page 182 - CA_Blue( J )_Class9
P. 182
13 System.out.print("Enter time : ");
14 t=sc.nextDouble();
15 System.out.print("Enter 1 for Simple Interest/ 2 for Compound
Interest : ");
16 ch=sc.nextInt();
17 switch(ch)
18 {
19 case 1 : si=(p*r*t)/100.0;
20 System.out.println("Simple Interest : "+si);
21 break;
22 case 2 : a = p * Math.pow((1 + (r/100.0)),t);
23 ci = a - p;
24 System.out.println("Compound Interest : "+ci);
25 break;
26 default: System.out.println("Wrong Choice");
27 }
28 }
29 }
You will get the following output:
Program 5 Write a menu-driven program to calculate:
a) Area of a circle
b) Area of a square
c) Area of a rectangle
Input any one choice(c for circle / s for square / r for rectangle) and calculate the Area
according to the choice.
1 import java.util.*;
2 class chapter7_17
3 {
4 public static void main()
5 {
180 Touchpad Computer Applications-IX

