Question
This is my code in NetBeans Java. I am not getting the correct results. /* * To change this license header, choose License Headers in
This is my code in NetBeans Java. I am not getting the correct results. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package u3a1_debugfixifstmts; import java.util.Scanner; /** * * @author omora */ public class U3A1_DebugFixIFStmts { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here System.out.println("Teacher's Copy"); 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"); } } The requirements of this application are as follows: The application is to prompt the user to enter 3 integers representing three choices of numbers between 1 and 7. An integer value of zero means a choice has not been made yet. The application then determines and prints out the state of the choices made. That is the application determines and prints out the number of choices made and their values. The three choices have restrictions on them based on their order. The choices are made in order such that if the user did not make a first choice of a number between 1 and 7 (first integer is zero), the user cannot make a second or a third choice. An example of the three integers in this case would be: 0 0 0 Similarly, if the user makes a first choice (first integer is non-zero), but did not make a second choice (second integer is zero), the user cannot make a third choice. An example of the three integers in this case would be: 2 0 0 and so on. There is no need to validate the entered three integers to ensure they comply with the above rules. (Choices are between 1 and 7 and are entered in order.) Assume the entered data will be valid. Use these valid sets of data for testing: 0 0 0 2 0 0 1 4 0 7 5 7 Successful completion of this assignment will show the number of non-zero choices made by the user and their values when the application is run. Your program output should look like this sample output:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started