a do-while loop!!! sorry

import java.io.*;
import java.util.*;

public class guessing
{

public static void main (String args[])
{

System.out.print("Enter your guess, if you are correct you will be a winner  ");
{
if (Input< 1 || Input > 100)
System.out.print("your guess should be between 1 and 100!  ");

else if (Input > answer)// creates the too high

else if (Input < answer) //creates too low

else
System.out.print("You are a winner!!");
}

}
}

Edited by dorotalp91: n/a

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by donaldw
boolean b = true;

do {
....
//do something with the b variable
....
} while (b);

The loop will terminate when the answer is found.

int Input ;
do
{
System.out.print("Enter your guess, if you are correct you will be a winner  ");
if (Input< 1 || Input > 100)
System.out.print("your guess should be between 1 and 100! ");

else if (Input > answer)// creates the too high

else if (Input < answer) //creates too low
else
System.out.print("You are a winner!!");

Edited by ejosiah: n/a

do

if (Input< 1 || Input > 100)
System.out.print("your guess should be between 1 and 100!  ");

else if (Input > answer)// creates the too high

else if (Input < answer) //creates too low