-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBabyCalculator.java
More file actions
44 lines (36 loc) · 832 Bytes
/
Copy pathBabyCalculator.java
File metadata and controls
44 lines (36 loc) · 832 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
41
42
43
44
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment_10528808;
/**
*
* @author Mawutor
*/
import java.util.Scanner;
public class BabyCalculator
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
double a, b, c;
String op;
do
{
System.out.print("> ");
a = keyboard.nextDouble();
op = keyboard.next();
b = keyboard.nextDouble();
if ( op.equals("+") )
c = a + b;
else
{
System.out.println("Undefined operator: '" + op + "'.");
c = 0;
}
System.out.println(c);
System.out.println("Bye now");
} while ( true );
}
}