The Student Room Group

Need help with creating a postfix calculator in java using scanner

so far i have this but i cant get it to work:frown:

import java.util.Scanner;


public class v3 {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);
String operation;

do{

System.out.println("Enter your postfix expression, OR to exit type stop. : ");

operation = scanner.nextLine();

String [] expression = operation.split(" ");

if(expression.length < 1)
System.out.println ("Sorry invalid output");



for ( int i = 0; i < expression.length; i++) {


}}while(!operation.equals("stop"));

/*if

(number.equals("+"))
System.out.println("yes");

else if (number.equals("-"))
System.out.println("");

else if (number.equals("/"))
System.out.println("");

else if (number.equals("*"))
System.out.println("");
*/
}

}

Quick Reply

Latest

Trending

Trending