Debug and Fix If Statements
In this assessment, you will debug and fix a given Java console application that uses if statements,
but the application does not compile nor execute. You can use either the Toolwire environment or
your local Java development environment to complete this assignment.
The application has four bugs. Your assignment is to find these bugs and fix them so that the
application meets its stated requirements.
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:
Follow these steps to complete this assignment:
1. Unzip the attached NetBeans project zip file (U3A1_DebugFixIFStmts.zip) and load it into
your NetBeans IDE.
2. Debug and fix the application to meet its stated requirements.
3. Compile and test your application using the provided input data.
Make sure to document the result of your testing by taking screenshots of the result of
running your application similar to the provided sample output. Four screenshots are
required for this assignment.
Explain the approach you took to complete this assignment and the major decisions you made. As
part of your explanation, be sure to identify the fundamental Java constructs you used that were
specific and relevant to your submitted program.
5
Deliverables
Use the submission template provided in the resources
(WeekX
Solution
SubmissionTemplate.docx) to complete and submit your deliverables. Your
deliverables in the attached submission template should include:
1. Your work. (Netbeans project zip file + copy of *.java source code.)
2. .
Debug and Fix If Statements In this assessment, you will d.docx
1. Debug and Fix If Statements
In this assessment, you will debug and fix a given Java console
application that uses if statements,
but the application does not compile nor execute. You can use
either the Toolwire environment or
your local Java development environment to complete this
assignment.
The application has four bugs. Your assignment is to find these
bugs and fix them so that the
application meets its stated requirements.
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:
2. 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
3. and their values when the application is run. Your program
output should look like this sample output:
Follow these steps to complete this assignment:
1. Unzip the attached NetBeans project zip file
(U3A1_DebugFixIFStmts.zip) and load it into
your NetBeans IDE.
2. Debug and fix the application to meet its stated requirements.
3. Compile and test your application using the provided input
data.
Make sure to document the result of your testing by taking
screenshots of the result of
running your application similar to the provided sample output.
Four screenshots are
4. required for this assignment.
Explain the approach you took to complete this assignment and
the major decisions you made. As
part of your explanation, be sure to identify the fundamental
Java constructs you used that were
specific and relevant to your submitted program.
5
Deliverables
Use the submission template provided in the resources
(WeekX
Solution
SubmissionTemplate.docx) to complete and submit your
deliverables. Your
deliverables in the attached submission template should include:
1. Your work. (Netbeans project zip file + copy of *.java source
code.)
2. Screenshots of the result of testing your application. See the
examples provided.
5. 3. Explain the approach you took to complete this assignment
and the major decisions you
made. As part of your explanation, be sure to identify the
fundamental Java constructs
you used that were specific and relevant to your submitted
program.
Your work will be scored on the following criteria:
1. Identify bugs in a program using development tools.
2. Code an application to fix bugs.
3. Test the application and document testing.
4. Explain the approach taken to complete the fix and the major
decisions made.
5. Identify relevant fundamental constructs in submitted
program.
6. Communicate efficiently, effectively, and in an appropriate
manner as an IT professional.
6. Debug and Fix If StatementsDeliverables
U3A1_DebugFixIFStmts/build.xml
Builds, tests, and runs the project U3A1_DebugFixIFStmts.
U3A1_DebugFixIFStmts/build/classes/.netbeans_automatic_buil
d
U3A1_DebugFixIFStmts/build/classes/.netbeans_update_resourc
es
U3A1_DebugFixIFStmts/build/classes/u3a1_debugfixifstmts/U3
A1_DebugFixIFStmts.classpackage u3a1_debugfixifstmts;
publicsynchronizedclass U3A1_DebugFixIFStmts {
public void U3A1_DebugFixIFStmts();
publicstatic void main(String[]);
}
U3A1_DebugFixIFStmts/manifest.mf
7. Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
U3A1_DebugFixIFStmts/nbproject/build-impl.xml
Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar
34. build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection
transport:
#debug.transport=dt_socket
debug.classpath=
35. ${run.classpath}
debug.test.classpath=
${run.test.classpath}
# Files in build.classes.dir which should be excluded from
distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/U3A1_DebugFixIFStmts.jar
dist.javadoc.dir=${dist.dir}/javadoc
excludes=
includes=**
jar.compress=false
36. javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.processorpath=
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=
${javac.classpath}:
${build.classes.dir}
javac.test.processorpath=
41. /**
* @param args the command line arguments
*/
publicstaticvoid main(String[] args){
// TODO code application logic here
System.out.println("Teacher's Copy");
Scanner input =newScanner(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)
42. System.out.println("State of choices: n"+
"user made first choice ("+ firstChoice +")n"+
"number of choices = 1");
elseif(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")
}
}
Remove or Replace: Header Is Not Doc Title
Name:
Date:
Class: IT2249
Unit:
43. Insert here a copy of your zip file of all of your NetBeans
project files so that it could be unzipped, loaded and run in
another NetBeans:
Insert here a copy of your *.java source code text that you used
here (copy and paste source code here, do not simply insert
*.java files):
Insert here a screenshot showing the result of testing your
application as directed by the assignment:
Explain your approach you took to complete this assignment
and the major decisions you made: