-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmeticOperations.java
More file actions
76 lines (70 loc) · 1.5 KB
/
ArithmeticOperations.java
File metadata and controls
76 lines (70 loc) · 1.5 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.*;
class ArithmeticOperations
{
public static int addition(int a, int b)
{
int c;
c=a+b;
return c;
}
public static int subtraction(int a, int b)
{
int c;
c=a-b;
return c;
}
public static int multiplication(int a, int b)
{
int c;
c=a*b;
return c;
}
public static int division(int a, int b)
{
int c;
c=a/b;
return c;
}
public static int modulus(int a, int b)
{
int c;
c=a%b;
return c;
}
public static void main(String[] args)
{
int n1,n2,x;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the First Number -");
n1=sc.nextInt();
System.out.print("Enter the Second Number :- ");
n2=sc.nextInt();
System.out.print("Enter 1 to Add. Enter 2 to Subtract. Enter 3 to Multiply. Enter 4 to Divide. Enter 5 to Modulus.");
x=sc.nextInt();
if(x==1)
{
int d=addition(n1,n2);
System.out.print("The sum of"+n1+" and "+n2+" is : "+d);
}
else if(x==2)
{
int d=subtraction(n1,n2);
System.out.print("The diffence of"+n1+" and "+n2+" is : "+d);
}
else if(x==3)
{
int d=multiplication(n1,n2);
System.out.print("The Product of"+n1+" and "+n2+" is : "+d);
}
else if(x==4)
{
int d=division(n1,n2);
System.out.print("The Quotient of"+n1+" and "+n2+" is : "+d);
}
else if(x==5)
{
int d=modulus(n1,n2);
System.out.print("The Reminder of"+n1+" and "+n2+" is : "+d);
}
}
}