vendredi 12 juillet 2019

What is wrong with these if statements? [on hold]

Code is not running I want the below code to prompt me to enter integers but the code is not running.

System.out.println("Integer Test");

Scanner input = new Scanner(System.in);

// prompt the user to enter 3 ints
// and read them into
// firstChoice
//secondChoice
//thirdChoice
System.out.print("Enter three integers: ");
int firstChoice = input.nextInt();
int secondChoice = input.nextInt();
int thirdChoice = input.nextInt();

//Determine & print the state of choices made
if (firstChoice == 0)
    System.out.println("State of choices: \n" +
            "no choices made yet");
if (secondChoice == 0)
    System.out.println("State of choices: \n" +
            "user made first choice (" + firstChoice + ")\n" +
            "number of choices = 1");
else if (thirdChoice = 0)
    System.out.println("State of choices: \n" +
            "user made first choice (" + firstChoice + ")\n" +
            "user made second choice (" + secondChoice + ")\n" +
            "number of choices = 2");

    System.out.println("State of choices: \n" +
            "user made first choice (" + firstChoice + ")\n" +
            "user made second choice (" + secondChoice + ")\n" +
            "user made third choice (" + thirdChoice + ")\n" +
            "number of choices = 3")

Aucun commentaire:

Enregistrer un commentaire