Hello Everyone I was instructed to do the following but came up with 10 errors which are listed below can anyone please help with this.
Write a sentinel loop that will sum all positive integer values entered; use a negative number to end the loop. Be sure to test for valid data entry; if data entered is incorrect give the user and error message and have them re-enter the value until they enter in an integer.
Assume: console is a Scanner object that was initialized to the keyboard.
public class positiveinteger {
public static void main(String[] args) {
int inputNumber;
int sum;
int count;
sum = 0;
count = 0;
TextIO.put("Enter your first positive integer: ");
inputNumber = TextIO.getlnInt();
while (inputNumber != 0) {
sum += inputNumber;
count++;
TextIO.put("Enter your next positive integer, or 0 to end: ");
inputNumber = TextIO.getlnInt();
}
/* Display the result. */
if (count == 0) {
TextIO.putln("You didn't enter any data!");
}
else {
average = ((double)sum) / count;
TextIO.putln();
TextIO.putln("You entered " + count + " positive integers.");
TextIO.putf("Their average is %1.3f.\n", average);
}
} // end main()
} // end class positiveinteger
ERROR CODES:
location: class positiveinteger
TextIO.putln("You didn't enter any data!");
^
positiveinteger.java:28: cannot find symbol
symbol : variable average
location: class positiveinteger
average = ((double)sum) / count;
^
positiveinteger.java:29: cannot find symbol
symbol : variable TextIO
location: class positiveinteger
TextIO.putln();
^
positiveinteger.java:30: cannot find symbol
symbol : variable TextIO
location: class positiveinteger
TextIO.putln("You entered " + count + " positive integers.");
^
positiveinteger.java:31: cannot find symbol
symbol : variable average
location: class positiveinteger
TextIO.putf("Their average is %1.3f.\n", average);
^
positiveinteger.java:31: cannot find symbol
symbol : variable TextIO
location: class positiveinteger
TextIO.putf("Their average is %1.3f.\n", average);