jeudi 5 février 2015

My if else statement is not working properly [on hold]

We have to create a program in java that is kind of like a quiz, but my else statement keeps saying correct for every answer given. Here is what I have.



import java.util.Scanner;
public class Project03 {

public static void main(String[] args) {

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter your name:");
String name = keyboard.nextLine();
System.out.println("Welcome:" + name );
System.out.println("Please answer the following questions:\n" + "What is 4 + 6 \n");
keyboard.nextLine();

int x = 10;

if (x == 10){
System.out.println("Correct!");
}else{
System.out.println("Incorrect!");
}
}
}

Aucun commentaire:

Enregistrer un commentaire