-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc.java
47 lines (45 loc) · 941 Bytes
/
calc.java
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
package calculator;
public class calc {
private String name;
/*public calc(String name2) {
this.name=name;
}*/
public void addition(double a,double b) {
if(a>=0 && b>=0) {
double c=a+b;
System.out.println("The Sum is "+c);
}
else {
System.out.println("Invalid input");
}
}
public void subtraction(double a,double b) {
if(a>=0 && b>=0) {
double c=a-b;
System.out.println("The Answer is "+c);
}
else {
System.out.println("Put positive values");
}
}
public void multiply(double a,double b) {
if(a>=0 && b>=0) {
double c=a*b;
System.out.println("The Product is "+c);
}
else {
System.out.println("Enter positive values");
}
}
public void divide(double a,double b) {
if(a>=0 && b>=0) {
double c=a/b;
System.out.println("The Quotient is "+c);
double d=a%b;
System.out.println("The Remainder is "+d);
}
else {
System.out.println("Wrong values entered");
}
}
}