I can't figure out a way to have this program continue to loop if you press any number other than 1 or 2.
Here's the test appilcation.
public class AnalysisTest
{
public static void main( String args[] )
{
Analysis application = new Analysis(); // create Analysis object
application.processExamResults(); // call method to process results
} // end main
} // end class AnalysisTest
My problem is in the class below.
This is what i have so far. Im thinking of putting this in there replace the if statement.
if ( result == 0 )
continue;
if ( result >= 3 )
continue;
if ( failures == 0 )
continue;
if ( failures >= 3 )
continue;
if ( result == 1 ) // if result 1,
passes = passes + 1; // increment passes;
else ( failures == 2 ) // else result is not 1, so
failures = failures + 1; // increment failures
I can't figure it out for some reason :(
I did this in BASIC and I can't remember how.
import java.util.Scanner;
public class Analysis
{
public void processExamResults()
{
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
// initializing variables in declarations
int passes = 0; // number of passes
int failures = 0; // number of failures
int studentCounter = 1; // student counter
int result; // one exam result (obtains value from user)
// process 10 students using counter-controlled loop
while ( studentCounter <= 10 )
{
// prompt user for input and obtain value from user
System.out.print( "Enter result (1 = pass, 2 = fail): " );
result = input.nextInt();
// if...else nested in while
if ( result == 1 ) // if result 1,
passes = passes + 1; // increment passes;
else // else result is not 1, so
failures = failures + 1; // increment failures
// increment studentCounter so loop eventually terminates
studentCounter = studentCounter + 1;
} // end while
// termination phase; prepare and display results
System.out.printf( "Passed: %d\nFailed: %d\n", passes, failures );
// determine whether more than 8 students passed
if ( passes > 8 )
System.out.println( "Raise Tuition" );
} // end method processExamResults
} // end class Analysis