-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSimpleCalculator.java
More file actions
58 lines (45 loc) · 1.24 KB
/
SimpleCalculator.java
File metadata and controls
58 lines (45 loc) · 1.24 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
import java.util.Scanner;
/**
* Example of a simple calculor. This class represents a typical student submission
* @author gue
*
*/
public class SimpleCalculator
{
/**
* Starts the calculator
* @param args
*/
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println("Welcome to the simple Calculator");
System.out.println("================================");
System.out.println("******* written by hg *********");
System.out.println("================================");
System.out.println("OK lets go: 123");
System.out.println("Enter the first integer");
int a = s.nextInt();
System.out.println("Enter the operation [+, -, *]");
String op = s.next();
System.out.println("Enter the second integer");
int b = s.nextInt();
switch(op)
{
case "+":
System.out.println("The sum of " + a + " + " + b + " = " + (a+b));
break;
case "-":
System.out.println("The difference of " + a + " - " + b + " = " + (a-b));
break;
case "*":
System.out.println("The multiplication of " + a + " * " + b + " = " + (a*b));
break;
default:
System.out.println("I dont know what to do");
break;
}
s.close();
System.exit(111);
}
}