1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Veronika [31]
3 years ago
7

Write a program with a loop that lets the user enter a series of positive integers. The user should enter −1 to signal the end o

f the series. The program should count all the numbers entered, compute the running total of the numbers and displays their count, total and average. Display average to decimal places.
Computers and Technology
1 answer:
Fiesta28 [93]3 years ago
5 0

Answer:

import java.util.Scanner;

public class num2 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int count =0;

       int total = 0;

       System.out.println("Enter the numbers");

       int num = in.nextInt();

       while(num!=-1){

           total = total+num;

           count++;

           System.out.println("Enter the next number");

           num = in.nextInt();

       }

//Compute the average

       double average = (double) total/count;

//Outputs

       System.out.println("Total count of numbers entered "+(count));

       System.out.println("Sum of the numbers "+total);

       System.out.printf("Average is %.2f ",average);

   }

}

Explanation:

  • Using java programming language
  • Import scanner class to receive user input
  • declare variables count and total and initialize to zero
  • Prompt user to enter numbers
  • Use a while statement with the condition while(num!=-1)
  • Within the while body keep prompting user to enter a number, increase count and update total
  • when -1 is entered the loop breaks and average is calculated
  • Use printf() method to print average to 2 decimal places.
You might be interested in
A(n) _____ chart is drawn on the same worksheet as the data.
Harrizon [31]
The answer is An embedded chart
6 0
3 years ago
In cell D5, enter a formula to calculate the number of days for the first workshop. Add 1 to the results to include the total nu
iris [78.8K]

Answer:

D7

Explanation:

5 0
3 years ago
Substance abuse is an _____ coping mechanism.
hichkok12 [17]
Mental coping mechanism.
7 0
3 years ago
​A(n) ____ statement can include rules for site visitors, a statement of copyright in the site design and content, and can restr
laiz [17]

Answer: TOS

Explanation:

 Terms of service is the agreement and the set of rules and regulations for the site visitors. It include all the terms and condition or the disclaimer when addressing the particular website.

Terms of service are set before designing the any type of the site and content in the system that restrict all the types of business that the users conduct in the site.

7 0
2 years ago
When was technology created?
ANEK [815]

Answer:

two million years ago

Thomas Edison, American inventor who, singly or jointly, held a world-record 1,093 patents. In addition, he created the world's first industrial research laboratory.

3 0
1 year ago
Other questions:
  • This is going to get taken down but I dont care add me on discord cause ima bored<br> -Red-#9847
    12·1 answer
  • Which of the following represents inbound logistics for a bookstore
    13·1 answer
  • How can supply and demand for different careers affect job stability and income?
    6·1 answer
  • The measure of the maximum amount of data that can travel through a computer’s communications path in a given amount of time is
    9·1 answer
  • How does an agile team maintain requirement?​
    9·2 answers
  • Fill in each blank with the correct step from the fetch-execute cycle.
    14·1 answer
  • Someone please help will mark as brainliest
    8·2 answers
  • TRUE OR FALSE: THE BUILDER'S CLUB IS A PAID SUBSCRIPTION.
    9·2 answers
  • Why is computer called information processing machine....?​
    6·2 answers
  • What are the benefits and drawbacks of a desktop utilising virtualisation and a server?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!