Westonci.ca is the premier destination for reliable answers to your questions, brought to you by a community of experts. Explore our Q&A platform to find reliable answers from a wide range of experts in different fields. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
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
We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.