Hi I'm new to this forum and to java, I have some work to do which requires that I have to write a program that reads in a list of whole numbers and that only even numbers
in the range 1-100 are accepted and both 'N' and 'n' terminate the program.
Here is what I have so far:
import java.util.*;
public class RepeatList
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int Number, Sum = 0;
char Choice;
do
{
System.out.println("Enter the list of whole numbers, terminated by -999");
Number = sc.nextInt();
while(( Number != -999)&& (Number <=100))
{
Sum = Sum + Number;
Number = sc.nextInt();
}
System.out.println("Sum is "+ Sum);
System.out.print("Do you want to repeat the ");
System.out.println(" Program ['Y' or 'N']");
Choice = sc.next().charAt(0);
} while( Choice != 'N');
}
}
Please can anyone help me out?
Rach