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
When preparing to communicate a solution to a design problem, you must:?
damaskus [11]
You must Examine the viewpoint of ur audiences
7 0
3 years ago
What would be a standard way for anyone outside an agile team( for example, delivery partner partner of the account, head of the
musickatia [10]

Answer:

He/She can refer the physical/digital kanboard ,which is maintained by the team

7 0
3 years ago
8.10 LAB: Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's a
Korvikt [17]

Answer:

// This program is written in C++ programming language

// Comments are used for explanatory purpose

// Program starts here

#include <iostream>

#include <string>

using namespace std;

// Declare variables

int inputvar;

// Declare output variable as array

int outputvar[32];

// Set a counter for binary array

int i = 0;

while (inputvar > 0) {

// Divide inputvar by 2 and store remainder in outputvar

outputvar[i] = n % 2;

inputvar/=2;

i++; // increment i by 1

}

// End of division

// Prin resulting array in reverse order

for (int j = i - 1; j >= 0; j--) {

cout << outputvar[j];

}

return 0;

}

// End of Program

3 0
4 years ago
. Service recovery refers to A. the ability to quickly restore service following a service failure and provide compensation. B.
san4es73 [151]

Answer:

A. the ability to quickly restore service following a service failure and provide compensation.

Explanation:

Systems like servers are bound to fail at some point. This is because, it either has running parts or electronic components that could overheat or get shorted due to external or internal malfunction.

The ability of system to quickly restore services and operation after it experiences a total system failure is called system recovery.

7 0
3 years ago
What features are provided by most GUIs?
PSYCHO15rus [73]

Windows is the answer

8 0
4 years ago
Other questions:
  • David needs to create a password. He uses "rtjjkliusfvwr." Which of the following best explains the weakness in his password?
    9·2 answers
  • If you were asked to subnet a network in such a way as to arrive at 6 network ids you would need to borrow 2 bits.
    7·1 answer
  • The______for our newest game keeps changing as we develop our concept and refine our goals.
    11·2 answers
  • A flowchart that depicts the relationships among the input, processing, and output of an AIS is
    6·1 answer
  • Who invented autonomous cars? When I look it up it comes up as William Bertelsen but he invented the idea of hovering cars. Help
    8·1 answer
  • Describe a way in which a badly-designed or badly-constructed STRUCTURAL subsystem might impact the PROPULSION subsystem.
    5·1 answer
  • When using a file name you have to use only lower case letters<br>true or false
    11·1 answer
  • How do buffers work?
    14·1 answer
  • The two parts of a packet are the certificate and the While storms could be a cause, power _________ are more likely to be cause
    11·1 answer
  • Select the correct answer.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!