mercredi 11 novembre 2015

How to test if else stetments?

i have been struggling with testing the if else and for loops here is the example can you pleas guide me how does the automated testing actually work for these statements?

for (int i=1; i<=10; i++){                     // for loop from 1 to 10
    System.out.println(" guess "+i+ ":");
    int guess = scan.nextInt();
    //if guess is greater than number entered 
    if(guess>number)
        System.out.println("Clue: lower");
    //if guess is less than number entered 
    else if (guess<number )
        System.out.println("Clue: Higher");
    //if guess is equal than number entered 
    else if(guess==number) {
        System.out.println("Correct answer after only "+ i + " guesses – Excellent!");

    } 

Aucun commentaire:

Enregistrer un commentaire