-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLessonThree.java
More file actions
47 lines (35 loc) · 1.02 KB
/
LessonThree.java
File metadata and controls
47 lines (35 loc) · 1.02 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
package Lesson03;
import logic.Lesson;
import java.util.Scanner;
public class LessonThree extends Lesson {
@Override
public void theLesson() {
Scanner input = new Scanner(System.in);
int num1;
int num2;
String operation;
int answer;
System.out.print("Give me your first number: ");
num1 = input.nextInt();
System.out.print("Give me your second number: ");
num2 = input.nextInt();
System.out.print("What should I do to these numbers? ");
operation = input.next();
if (operation.equals("+")) {
answer = num1 + num2;
} else if (operation.equals("-")) {
answer = num1 - num2;
} else if (operation.equals("*")) {
answer = num1 * num2;
} else if (operation.equals("/")) {
answer = num1 / num2;
} else {
answer = 0;
}
System.out.printf("The answer is %d", answer);
input.close();
}
@Override
public void theAssignment() {
}
}