String input = keyboard.nextLine();
Code :
import java.util.Scanner;
public class beraknaTal {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int resultat, tal1, tal2;
System.out.print("Ange ett heltal: ");
tal1 = keyboard.nextInt();
System.out.print("Ange ett till heltal: ");
tal2 = keyboard.nextInt();
do{
System.out.print(+tal1 + "+" +tal2 +"= ");
resultat = keyboard.nextInt();
}
while(resultat != tal1 + tal2);
System.out.println("You answered right, would you like to continue Yes or No ");
String input = keyboard.nextLine();
if (input.equals("No"))
System.out.println("Du behöver öva mer matematik");
if (input.equals("Yes"))
System.out.println("Då fortsätter vi då");
Why isnt it possible to write yes or no in the console=/?
Re: String input = keyboard.nextLine();
Where does the code write that to the console? Are there any conditions that must be true like in an if statement or a while statement that will prevent the code from executing?
If so, print out the values of the variables used in the condition so you can see what the program sees when it executes the statement with the condition.
Can you copy the contents of the console and paste it here so we can see what you see when you execute the program?