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
The network connection in Shirley's new office doesn't work. What tool would enable a tech to find the specific network cable fo
emmainna [20.7K]

Answer:

Toner probe

Explanation:

A Toner probe is a useful device for the installation of electrical cabling of any type, it can be used as Probe and Tone Tool: it enables someone in finding individual leads among a large number in a cable trunk, without having to either connect or strip the remote end.

Its major use is to trace wires or cables by sending a signal from one end of a wire down its entire length. This is typically done to track the spot of a cut or missing door, window, or other alarm wire.

8 0
4 years ago
By default, the windows password policy requires a minimum password of what length?​ select one:
kramer
<span>7 characters are the default for WIN7/8/10. This can, of course, be changed many ways via the registry or via a GPO.</span>
7 0
3 years ago
Which column and row references are updated when you copy the formula =$A1+B$10 Select all that apply.
lora16 [44]

Answer:

c

Explanation:

4 0
3 years ago
Read 2 more answers
An identifier that allows multiple elements in an HTML document to be<br> styled in the same way
oksian1 [2.3K]

Answer:

CSS , (Possibly Divs)

Explanation:

I have picked CSS, and possibly Div's as my main explanation and answer here is why.

CSS - Cascading Style Sheets, this allows you to edit multiple elements in a HTML document, such as the color or any CSS attribute.

If you would like to learn more about CSS, and the multiple options that CSS provides such as Internal Styles, External Styles, lastly In-line styles. I highly recommend the resource "W3Schools".

DIV's - Divs are basically like a container, where you can input styles into this container that can effect those elements such as if I want the background-color, of the div it would effect all the elements inside that div. However, I said this could be a possibility since it isn't CSS where it is styled however you can group these elements to one div. You can also edit the CSS of the Div to effect it.

6 0
3 years ago
When you point to defined styles in the cell styles gallery, you can see the formatting that will be used when you apply each st
Dvinal [7]
Hello  <span>Missthang2456 </span>

Question: <span>When you point to defined styles in the cell styles gallery, you can see the formatting that will be used when you apply each style?


Answer: This is true

Hope This Helps!
-Chris</span>
4 0
3 years ago
Other questions:
  • Here are some instructions in English. Translate each of them into the Simple Machine language.
    12·1 answer
  • I have a question involving do and for loops while using arrays.
    8·1 answer
  • A rugby team has 15 players. A bus company has big buses that can carry 48 passengers and small buses that can carry 10 passenge
    10·1 answer
  • an individual’s Body Mass Index (BMI) is a measure of a person’s weight in relation to their height. it is calculated as follows
    6·1 answer
  • Why is failure an important part of life and the engineering design process?
    13·2 answers
  • An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself), is equal to the n
    9·1 answer
  • What command can you use if you accidentally delete a sentence in your document?
    13·2 answers
  • What is radial gradient in Flash CS3
    6·1 answer
  • You are writing code to store the length of a side of a square. Which one is a good variable name
    9·1 answer
  • Describe the five components of a computer
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!