-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculus.java
More file actions
40 lines (30 loc) · 856 Bytes
/
calculus.java
File metadata and controls
40 lines (30 loc) · 856 Bytes
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
import java.util.Scanner;
public class calculus {
public static void main(String[] args) {
Scanner inputData = new Scanner(System.in);
System.out.println("Please enter an integer to begin: ");
int num1 = inputData.nextInt();
System.out.println("Please write the operator you want to use: ( + , - , / , * )");
char operator;
operator = inputData.next().charAt(0);
System.out.println("Please enter another integer: ");
int num2 = inputData.nextInt();
if(operator == '+') {
System.out.println(num1+num2);
}
else if(operator == '-') {
System.out.println(num1-num2);
}
else if(operator == '/') {
System.out.println(num1/num2);
}
else if(operator == '*')
{
System.out.println(num1*num2);
}
else
{
System.out.println("Wrong operator");
}
}
}