Page 132 - CA_Blue( J )_Class10
P. 132
25 case 1 : add=a+b;
26 System.out.println("Sum : "+add);
27 break;
28 case 2 : pro=a*b;
29 System.out.println("Product : "+pro);
30 break;
31 case 3 : sub=a-b;
32 System.out.println("Difference : "+sub);
33 break;
34 case 4 : quo=(double)(a)/(double)(b);
35 System.out.println("Quotient : "+quo);
36 break;
37 default: System.out.println("Wrong Choice");
38 }
39 }
40 }
You will get the following output:
7.8 TERMINATE PROGRAM USING SYSTEM.EXIT()
The System.exit() function is used to stop the program immediately whenever required. This function terminates the
Java Virtual Machine (JVM). It does not return any value. There are two types of terminations using System.exit()
function:
1. To exit normally, we use System.exit(0).
2. To have an abnormal exit, System.exit(1) or System.exit(-1) or any other non-zero value is used.
To input rate of an item and number of quantities required. Calculate the total amount required
Program 11
to buy the item. The rate and quantity should be a positive value else the program will stop.
1 import java.util.*;
2 class systemexit
3 {
4 public static void main()
130130 Touchpad Computer Applications-X

