Write a code fragment that allows a user to continue inputting numbers until she enters a sentinel value of 0. Then print the sum of all the numbers she entered. You may assume that a Scanner object named input has already been created.

What will be an ideal response?


```
int sum = 0;
int inputInt;
do {
System.out.print("Please enter an integer (0 to quit): ");
inputInt = input.nextInt();
sum += inputInt;
}while(inputInt != 0);
System.out.println("The sum of the numbers is " + sum);
```

Computer Science & Information Technology

You might also like to view...

Discuss baseband versus broadband.

What will be an ideal response?

Computer Science & Information Technology

The CONCATENATE function joins two or more ____ into one.

A. strings B. formulas C. cells D. functions

Computer Science & Information Technology

As computers become faster, memory access speeds are not keeping pace.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

To ensure the integrity of the Windows operating system code, the designers separated operating system functions into a privileged executive process and a set of nonprivileged processes called protected subsystems.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology