-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCalc.java
More file actions
44 lines (33 loc) · 1.24 KB
/
TestCalc.java
File metadata and controls
44 lines (33 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
//Name: Wyatt Bechtle
//Date: 9 April 2023
//Program: Test Calculator Class
//Algorithm
//---------
//Step 1) Display ">>>" prompt.
//Step 2) Pass user input to parseInput.
//Step 3) Display return values if needed.
//Step 4) Do again.(Inifinite loop)
import java.util.Scanner;
public class TestCalc {
public static void main (String [] args) {
//Create calculator object for arithmetic.
Calculator calcObject = new Calculator();
//Create scanner object to get input from keyboard.
Scanner scannerObject = new Scanner(System.in);
//Declare variable for user input.
String userInput;
//Declare string variable to receive data from the class.
String calcClassOutput;
do {
//Display input prompt and get input.
System.out.print(">>>");
userInput = scannerObject.nextLine();
//Pass the input to calc's parse input method.
calcClassOutput = calcObject.parseInput(userInput);
//Check if there is anything to display.
if (!calcClassOutput.isEmpty()) {
System.out.println(calcClassOutput);
}
} while (true);
}
}