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
Hi Guys,
Bingel [31]

Answer:

Please check the attachment.

Explanation:

Please check the attachment.

Download docx
8 0
4 years ago
Becca is working on a program that will store data. The program will need quick access to data and data persistence is not impor
tester [92]

Answer:

A developer wants to take existing code written by another person and add some features specific to their needs.

Explanation:

pls Mark as Brain list

3 0
3 years ago
Create a java program that creates two files. Fill each file with 100 random integer numbers between 1 and 20.
Nana76 [90]

Answer:zxsdfghjgfghghmncvbn

Explanation:bnmgfdghjkjhgfgbcxdnmxc  vnchdg  cbhd

4 0
3 years ago
You can move to the previous or next sheet by pressing the ____ keys.
Paladinen [302]
<span>ctrl+pg up (or ctrl) + pg down</span>
8 0
3 years ago
A network administrator for a small company is contemplating how to scale the network over the next three years to accommodate p
choli [55]

Answer:

Option B,C,E

Explanation:

4 0
3 years ago
Other questions:
  • The collodion process was significantly more expensive than the cost of a daguerreotype
    10·1 answer
  • FINISH THE SENTENCE <br><br> buzzfeed____reddit_____
    5·1 answer
  • Will a pair of bar magnet ,with keepers on the two ends, act as a magnet
    13·1 answer
  • (A) writer or word <br> (B) Calc or Excel <br> (C) impress or PowerPoint<br> (D) none of these
    14·1 answer
  • For most applications, saving sound files at the _____ bit resolution provides a good balance of sound quality and file size.
    15·2 answers
  • How can our perceptions help us to choose the channel for our message?
    5·1 answer
  • The relational database is the primary method for organizing and maintaining data today in information systems. It organizes dat
    9·1 answer
  • What will you see on the next line?
    6·2 answers
  • In java please
    13·1 answer
  • Helppppp meeee eeeeeee eee
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!