Thanks Question 38 Not yet answered Points out of 10 P Flag

Thanks!
Question 38 Not yet answered Points out of 10 P Flag question Write a program with a loop that lets the user enter a series of exam scores taken for a student. Each score entered should be added to a total. Give the user instructions to enter a negative value to indicate the end of the series. After all the numbers have been entered, the program should display Total scores:\" followed by the total

Solution

public class Student{
  
public static void main(String[] args) {
  
int inputNumber;   
int sum;   
int count;   
sum = 0;
count = 0;
  
  
System.out.print(\"Enter your first positive integer: \");
inputNumber = TextIO.getlnInt();
  
while (inputNumber >0) {
sum += inputNumber;
count++;
System.out.print(\"Enter your next positive integer, or negative number to end: \");
inputNumber = TextIO.getlnInt();
}
  
if (count == 0) {
System.out.println(\"You didn\'t enter any data!\");
}
else {
System.out.println(\"You entered \" + count + \" posit
System.out.printf(\"Their sum is\",+sum);
}

}

}

Thanks! Question 38 Not yet answered Points out of 10 P Flag question Write a program with a loop that lets the user enter a series of exam scores taken for a s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site