Im having some trouble figuring out how to write this program
Write a program to take a sequence of integer values between zero to 200 (not inclusive of zero; inclusive of 200) from the console. Stop requestiing values when the input is less than o equal to he immediate, previously enetered value. The program should then output the total number of valid data entered ( ending input not included in data), and the decimal average of all data displayed to two places after the decimal.
Example run
Enter value: 10
Enter value: 0
** Invalid ** Enter value: -10
** Invalid ** Enter value: 20
Enter value : 34
Enter value: 29
Data count = 3
Average of data = 21.33
Heres what I got so far
import java.util.*;
public class Aw {
public static void main(String [ ] args) {
Scanner console = new Scanner(System.in);
int value = 1;
int prevalue = 0;
while (value > prevalue) {
System.out.print("Enter value: ");
int v = console.nextInt();
}
}
}
Im having trouble setting the variables for value and prevalue so that i can make this while loop stop.
Any help at all would be greatly appreciated, Ive spent so much time reading my textbook. My instructor is doing a bad job explaining things to our class and its hard to learn. thank you


Sign In
Create Account

Back to top









