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
Naily [24]
4 years ago
8

Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a

nd computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. Sample Run 1
Computers and Technology
1 answer:
nika2105 [10]4 years ago
3 0

Answer:

import java.util.Scanner;

public class NumbersStats {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int pos = 0, neg = 0, count = 0, num;

       double total = 0;

       System.out.print("Enter an integer, the input ends if it is 0: ");

       while (true) {

           num = in.nextInt();

           if(num == 0) break;

           if(num > 0) {

               pos++;

           } else {

               neg++;

           }

           total += num;

           count++;

       }

       System.out.println("The number of positives is " + pos);

       System.out.println("The number of negatives is " + neg);

       System.out.println("The total is " + total);

       System.out.println("The average is " + (total/count));

   }

}

Explanation:

You might be interested in
What is the proper order for the fetch-execute cycle?
vesna_86 [32]

Control Unit – controls all parts of the computer system. It manages the four basic operations of the Fetch Execute Cycle as follows:

Fetch – gets the next program command from the computer’s memory

Decode – deciphers what the program is telling the computer to do

Execute – carries out the requested action

Store – saves the results to a Register or Memory

Arithmetic Logic Unit (ALU) – performs arithmetic and logical operations

Register – saves the most frequently used instructions and data

5 0
3 years ago
Como afecta la robotizacion en las empresas?
kirill [66]

Yo llamaria a esto automatizacion.

Puede reducir los costos al permitir que la empresa emplee a menos personas.

8 0
3 years ago
The windows 8 start screen has controls, also known as its ____, that allow you to interact with the windows 8 operating system.
Angelina_Jolie [31]
Password has the control over the computer
3 0
3 years ago
How many passes will it take to find the four in this list?
Vaselesa [24]
I don’t know what the heck is it true
3 0
3 years ago
Read 2 more answers
How to check iready minutes when i cannot log into iready
Alekssandra [29.7K]

Answer:

If you are the host of the iready like a teacher then you should be able to see how much time you have left. If not you should probably ask them.

Explanation:

3 0
3 years ago
Other questions:
  • What is the result of segmenting a network with a bridge (switch)? (Choose two)
    14·1 answer
  • How old do you have to be to get paid to wave at liberty tax in Abilene tx
    8·2 answers
  • This operating system was used by individual computers and required users to type commands.
    7·2 answers
  • A type of address translation in which a gateway has a pool of public ip addresses that it is free to assign to a local host whe
    8·1 answer
  • Make a program that prints each line of its input that mentions fred. (It shouldn’t do anything for other lines of input.) Does
    10·1 answer
  • Assemble a Server computer based on your budget (state the amount in Ghana Cedis), discussing the type of components (giving the
    11·1 answer
  • Which of the following is productivity strategy for collaboration?
    6·1 answer
  • Which is the fastest CPU and why?
    5·1 answer
  • Your sister has just emailed you an attached file with the invitation list for her upcoming party.
    11·2 answers
  • Hayne is starting his own business as a psychotherapist and needs to post a website advertising his services,contact information
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!