this program is an example of how a grade should compute
heres the code
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ConsoleApplicationsSamples; /** * * @author Administrator */ import java.util.*; public class Sample { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int grades, keyIn; keyIn = 1; do { System.out.print("Enter the grades: 1 for passed / 0 for failed"); grades = scanner.nextInt( ); if(grades == 1) System.out.println("PASSED"); else if (grades == 0) System.out.println("FAILED"); else if(grades > 1) System.exit(0); keyIn ++; } while(keyIn <= 10); if(grades <= 7) System.out.println("Stubborn"); //if i entered 7 time the it should print this else if(grades >= 8) System.out.println("NAKS SIPAG MAG ARAL AHH"); // but if i entered greater than 7 times then it // should print this } }
the looping of the input is fine , the selection inside the loop is still fine...
but the problem is the condition outside the loop, no matter how many 1(passed) or 0(failed) I enter
it only prints the first condition ("Stubborn") it always ignore the second one.
need help regarding this matter.. tnx a lot again