0
What am I doing Wrong in the following code?
import java.util.Scanner; public class Program { public static void main(String[] args) { //variables int firstNumber, secondNumber; String operation, a; //user input Scanner sc = new Scanner(System.in); System.out.println("Enter the first integer"); firstNumber = sc.nextInt(); System.out.println("Enter the operation in words(add, substract, multiply, devide):"); a = sc.nextLine(); operation = a.toLowerCase(); System.out.println("Enter the second integer"); secondNumber = sc.nextInt(); System.out.println(firstNumber); System.out.println(secondNumber); System.out.println(operation ); } }
5 ответов
+ 1
👆Take a look at above post...
And
Input in the form:
int String
int
Ex:
4 string
5
+ 1
After firstNumber = sc.nextInt();
You have to add "sc.nextLine();" - it will consume "\n" - new line