-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw
30 lines (27 loc) · 898 Bytes
/
hw
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
import java.util.Scanner;
public class jag{
public static void main(String[] args){
System.out.println("Welcome! Please input an integer.");
Scanner sc1 = new Scanner(System.in);
int num1 = sc1.nextInt();
System.out.println("Please input an operator: +, -, *, or /");
Scanner sc2 = new Scanner (System.in);
String operator = sc2.nextLine();
System.out.println("Please input another integer.");
Scanner sc3 = new Scanner (System.in);
String num2 = sc3.nextInt();
if(operator.equals("+"){
double result = (double) num1 + num2;
}
else if(operator.equals("-"){
double result = (double) num1 - num2;
}
else if(operator.equals("*"){
double result = (double) num1 * num2;
}
else if(operator.equals("/"){
double result = (double) num1 / num2;
}
System.out.println("Result: " + result);
}
}