-1

I want to be able to implement the System.in input into an if else statement, but have not quite found how, I'm a beginner with java and i'm creating a basic calculator.

//if input = fMultiply then multiply
    if () {
        answer = fnum * snum;
        System.out.println(answer);
    }
    else {

    }

basically I just want the System.in between the if () brackets.

1 Answers1

1

I would try something like this:

Scanner scanner = new Scanner (System.in); 
if(Integer.parseInt(scanner.next()) == fMultiply)
    System.out.println(fnum * snum);
John Howard
  • 50,339
  • 21
  • 44
  • 63