-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCal.java
More file actions
42 lines (41 loc) · 1.51 KB
/
Cal.java
File metadata and controls
42 lines (41 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.io.DataInputStream;
class Cal {
public static void main(String args[])
{ DataInputStream pt=new DataInputStream(System.in);
int x,y,z,ch;
try {
System.out.println("Enter Value of X:");
x = Integer.parseInt(pt.readLine());
System.out.println("Enter Value of Y:");
y = Integer.parseInt(pt.readLine());
System.out.println("1.Addition\n2.Subtraction \n3.Multiplication\n4.Division");
System.out.println("Enter ur choice:");
ch = Integer.parseInt(pt.readLine());
switch(ch)
{
case 1:
z = x + y;
System.out.println("The Addition is:"+z);
break;
case 2:
z = x - y;
System.out.println("The Subtraction is:"+z);
break;
case 3:
z = x * y;
System.out.println("The Multiplication is:"+z);
break;
case 4:
z = x / y;
System.out.println("The Division is:"+z);
break;
default:
System.out.println("Sorry Try Again.........");
break;
}
}
catch(Exception e)
{ System.out.println("x.getmessage()");
}
}
}