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
patriot [66]
4 years ago
14

Write a program, NumberStatistics.java, that reads an unspecified number of integers. The program ends with the input 0. The pro

gram determines the average of all positive values, the average of all negative values, the average of all the values, the maximum value, and the minimum value.
Computers and Technology
1 answer:
Lerok [7]4 years ago
6 0

Answer:

Following are the program, which can be below:

import java.util.*; //defining header file

public class NumberStatistics  //defining class NumberStatistics

{

public static void main(String[] arc) //defining main method

{

int total_number=0,max_val=0,min_val=0,neg_val=0,pos_val=0,neg_count=0,pos_count=0,x; //defining variables

Scanner ox= new Scanner(System.in); //creating Scanner class Object

System.out.println("Enter positive and negative value with sign and when complete inter 0:"); //print message  

x= ox.nextInt(); //input value from user

while(x!=0) //defining loop to check input value is 0

{

total_number++; // increment value

if(total_number == 1)  //defining conditional statement to check minimum and maximum value

{

max_val = x; //assign value in max  

min_val = x;//assign value in min

}

else  //defining else block

{

if(max_val < x) //check maximum value

{

max_val = x; //assign maximum value

}

if(min_val > x) //check minimum value

{

min_val = x; //assign minimum value

}

}

if(x > 0) //input values  

{

pos_count++; //count positive value

pos_val+=x; // add positive values

}

else  

{

neg_count++;//count negative value

neg_val+=x; // add negative values

}

x = ox.nextInt(); //input values

}

// defining conditionl statement

if(total_number != 0)  // defining if block to print all value

{

System.out.println("positive value average= "+(pos_val/(double)pos_count));

System.out.println("negative values Average= "+(neg_val/(double)neg_count));

System.out.println("all values average= "+(pos_val+neg_val)/(double)total_number);

System.out.println("maximum value = "+max_val+"\n"+" minimum value = "+min_val);

}

else  

{

System.out.println("no positive values found");

System.out.println("no negative values found");

}

}

}

Output:

Enter positive and negative value with sign and when complete inter 0:

12

8

04

22

-22

-5

9

0

positive value average= 11.0

negative values Average= -13.5

all values average= 4.0

maximum value = 22

minimum value = -22

Explanation:

The Description of the above java program can be described as follows:

  • In the above code first we import the package for user input, then defines the variable "total_number,max_val,min_val,neg_val,pos_val,neg_count, pos_count,x" to store the value prints its value.
  • In the next step, a scanner class object is created for user input and defines a while loop, that checks input value isn't equal to 0, inside the loop a conditional statement defines that cont and calculates all positive, negative, and all values addition.
  • At the another conditional statement is defines, that prints all value average, and also prints maximum, minimum value.
You might be interested in
MODS ONLY answer this, I have something for you. I'm reporting this to make it easier
aliya0001 [1]

Answer:

whyyyyy

have  a good day :)

Explanation:

7 0
3 years ago
What do you think are the IPO components in an online movie ticket booking system?
zalisa [80]

Explanation:

Online Movie Ticket Booking System is a website to provide the customers facility to book tickets for a movie online and to gather information about the movies and theaters. Customer needs to register at the site to book tickets to the movie

Advantages of Online Booking Systems

Your business is open around the clock. ...

You can maximize reservations. ...

You get paid quicker. ...

You're not tied to a phone. ...

You can effortlessly up-sell add-ons. ...

It's easy to manage your calendar. ...

You get valuable insight about your business

4 0
3 years ago
What are the contents of memory locations 200, 201, 202, and 203 if the word 1234 is stored at offset 200 and the word 5678 is s
Igoryamba

Answer:

Data at the following addresses will be as following:-

200 :- 34

201 :- 12

202 :- 78

203 :- 56

Explanation:

If there is 1 byte storage.

if the data is of 4 digits.Then we have to store it in 2 memory locations.

The first two digits will be stored at the higher byte address that is 201 and the last two digits will be stored at then lower byte address that is 200.

The case is same with the next data 5678.

At address 202 :- 78 will be stored and at address 203 :- 56 will be stored.

3 0
3 years ago
In which job role will you be creating e-papers, newsletters and preiodicals
gogolik [260]

Answer:

The correct answer is: newspaper editor.

Explanation:

Newspaper editors are responsible for creating and updating newspaper material, as well as other outlets such as magazines and, thanks to technology, online papers and newsletters. Such experts must have outstanding grammar and be informative as they are the last knowledge filter before they are sent to the public.

8 0
4 years ago
What could happen if we cannot save the life​
padilas [110]

Answer:

If we could not save the people or animals life they would die

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • Thomas Hill claims that a fruitful way to think about the badness of destroying the environment is
    15·1 answer
  • Marissa bought 2 and 1/2 gallons of orange juice to make punch how many quarts of orange juice did Marissa Buy
    15·2 answers
  • How can you tell if your car is overheating?
    12·2 answers
  • Your employer is opening a new location, and the IT director has assigned you the task of calculating the subnet numbers for the
    14·1 answer
  • Operating systems provide a measure of security by allowing users to access to those resources they've been cleared to use as we
    8·1 answer
  • The IBM nine-track tapes that became the industry standard for storage for three decades had several sizes , the most common bei
    13·1 answer
  • How do Computer Scientists use Binary Code?
    14·1 answer
  • What can hack or code can I use to get a shadow or frost dragon in adopt me
    6·2 answers
  • In many supermarkets customers can pay for their shopping using credit cards. (a) Name two items of information stored on the ma
    8·1 answer
  • 1. This tab displays the related commands which are grouped as Pages, Tables, Illustrations, Links, Header and Footer, Text, Sym
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!