Having an issue figuring out how to make this compile correctly. package DebugIF
ID: 3146460 • Letter: H
Question
Having an issue figuring out how to make this compile correctly.
package DebugIF;
import java.util.Scanner;
public class DebugIF {
public static void main(String[] args) {
System.out.println("Today we find the solutions");
Scanner input = new Scanner(System.in);
System.out.print("Enter three integers: ");
int firstChoice = input.nextInt();
int secondChoice = input.nextInt();
int thirdChoice = input.nextInt();
if (firstChoice == 0);
System.out.println("State of choices: " +
"no choices made yet");
if (secondChoice == 0)
System.out.println("State of choices: " +
"user made first choice (" + firstChoice + ") " +
"number of choices = 1");
else if (thirdChoice == 0)
System.out.println("State of choices: " +
"user made first choice (" + firstChoice + ") " +
"user made second choice (" + secondChoice + ") " +
"number of choices = 2");
System.out.println("State of choices: " +
"user made first choice (" + firstChoice + ") " +
"user made second choice (" + secondChoice + ") " +
"user made third choice (" + thirdChoice + ") " +
"number of choices = 3");
}
}
These are the outputs required for this project to work, it seems I get further behind trying to fix the issues.
Inputs for the program:
0 0 0
2 0 0
1 4 0
7 5 7
Successful out put displayed:
Today we find the solutions
Enter three integers: 0 0 0
State of choices:
no choices made yet
BUILD SUCCESSFUL
Today we find the solutions
Enter three integers: 2 0 0
State of choices:
user made first choice (2)
number of choices = 1
BUILD SUCCESSFUL
Today we find the solutions
Enter three integers: 1 4 0
State of choices:
user made first choice (1)
user made second choice (4)
number of choices = 2
BUILD SUCCESSFUL
Today we find the solutions
Enter three integers: 7 5 7
State of choices:
user made first choice (7)
user made second choice (5)
user made third choice (7)
number of choices = 3
BUILD SUCCESSFUL
Explanation / Answer
error is if (firstChoice == 0); that is semicolon should not be there.So the correct one is if(firstChoice == 0)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.