I need help with this code. it's basically a lotto program, but I only need to know how to get the 1st number right to do the rest. the user needs to be able to enter a number between 0 and 55. The program has to send an error message if the user enters a number less than or equal then zero and greater than or equal to 55, and an error message is needed for each. then after the error message is read the program has to allow the user to reenter the number. Then the program needs to bypass the error messages if the number entered is between 0 and 55 like it's supposed to be. it has to be done using a Do-while ad if-else statements. Each time I've enter a number that is between 0 and 55 the code goes ahead and beads the error messages anyway. How is this fixed in this code:

import java.util.Scanner;

public class FinalProgram
{
    public static void main(String[] args)
    {
Scanner keyboard = new Scanner(System.in);
    int number1 = 0,number2,number3,number4,number5, powerball;
    int numberCount = 0;
do
{
System.out.println("Enter a number between 0 and 55");
number1 = keyboard.nextInt();
if(number1 <= 0)
{
System.out.println("Invalid entry. The number must be greater than 0");
number1 = keyboard.nextInt();
}
else
if(number1 >= 55)
{
System.out.println("Invalid entry. The number must be less than 55");
number1 = keyboard.nextInt();
}
}while(number1 < 0 && number1 > 55);
System.out.println("Okay");
}
}

uh. never mind. I've solved a couple problems. I think I'll get it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.