Get the answers you need at Westonci.ca, where our expert community is dedicated to providing you with accurate information. Explore in-depth answers to your questions from a knowledgeable community of experts across different fields. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
The program illustrates the use of repetitive operations.
Repetitive operations are done by using loops such as while and for loops
The program in Java, where comments are used to explain each line is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
//This declares all required variables
int num,total = 0;
//This creates a Scanner object
Scanner input = new Scanner(System.in);
//This gets the initial input
num= input.nextInt();
//The following is repeated until the initial input is 0 or less
while(num > 0){
//This is repeated to get integer inputs
for(int i = 0;i<num;i++){
//This adds up all integer inputs
total+=input.nextInt();
}
//This prints the total inputs
System.out.println(total);
//This initializes total to 0
total = 0;
//This gets the initial input
num= input.nextInt();
}
}
}
The loop will be executed as long as initial input is a positive integer.
See attachment for sample run.
Read more about similar programs at:
https://brainly.com/question/14072658

Thank you for your visit. We are dedicated to helping you find the information you need, whenever you need it. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.