Repository navigation
Expand file tree
/
Copy pathConTest.java
More file actions
48 lines (39 loc) · 2.03 KB
/
Copy pathConTest.java
File metadata and controls
48 lines (39 loc) · 2.03 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
import java.util.Scanner;
public class ConTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Converter con = new Converter();
boolean cont = true;
System.out.println("Choose one of the following operations:\n" +
" Infix to postfix conversion (enter the letter i)\n" +
" Postfix expression evaluation (enter the letter p),\n" +
" Arithmetic expression evaluation (enter the letter a)\n" +
" Quit the program (enter the letter q)");
while(cont)
{
System.out.println("Choose an operation: ");
String choice = scan.nextLine();
switch(choice)
{
case "i":
System.out.println("Please enter an expression: ");
System.out.println("The postfix expression is: " + con.infixToPostfix(scan.nextLine()));
break;
case "p":
System.out.println("Please enter an expression: ");
System.out.println("The value of the postfix expression is:" + con.postfixValue(scan.nextLine()));
break;
case "a":
System.out.println("Please enter an expression: ");
System.out.println("The value of the arithmetic expression is: " + con.postfixValue(con.infixToPostfix(scan.nextLine())));
break;
case "q":
System.out.println("GoodBye!");
cont = false;
break;
default:
System.out.println("Wrong Menu Choice!");
}
}
}
}