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
Create a python program that display this
aleksley [76]

Answer:

vxxgxfufjdfhgffghgfghgffh

4 0
3 years ago
Which sql keyword is used to retrieve a minimum value from an attribute in a table
konstantin123 [22]

The SQL keyword that is often used to retrieve a minimum value from an attribute in a table is the MIN function.

<h3>What is the MIN Function? </h3>

The MIN Function is known to be a group found under Excel Statistical functions.

Note that the MIN often return the minimum value in any list of arguments and as such The SQL keyword that is often used to retrieve a minimum value from an attribute in a table is the MIN function.

Learn more about SQL from

brainly.com/question/25694408

#SPJ11

5 0
2 years ago
Read 2 more answers
To insert the information of the data-label attribute directly before the data cell value, the _____ property is used.
sattari [20]

Answer:

Content is the correct answer to the following blank.

Explanation:

In the following FIB, Content is the property that is used to input the data directly in the data-label attribute earlier than the data cell value. In other words, it is used to insert the data or info of the label of the data attribute straightly without any barrier in the data cell value. So, that's why the following answer is true.

4 0
3 years ago
Write calls to printf to display the variable x in the following formats:
lys-0071 [83]

Answer:

a) printf("%-5.3e",x);

b) printf("%10llu",x);

<h3>Explanation:</h3>

We can assign any value to x at the start of program:

For Example:

float x = 72.149;

Then in order to print exponential notation, left justified, in field size of 5 with 3 digits after the decimal point, we need to use the following format:

printf("%-5.3e",x);

where e represent exponential notation.

5 represents field size of 5 and 3 represents digits after decimal point.

In order to print x as right justified, in a 11 digit field, we need to use the following format:

printf("%10llu",x);

8 0
3 years ago
If a team member comes from a(n)________(fill in the blank) culture, he or she will be more likely to expect the team members to
OleMash [197]

collectivistic culture

6 0
3 years ago
Other questions:
  • Which type of software-generated problems can indicate that a software bug is causing a memory error?
    11·1 answer
  • Plz answer these questions...those who give answer get the brainliest......hurry up..!!!​
    14·1 answer
  • A ___ is the basic collective unit of data in a computer.
    12·1 answer
  • Which of the following is true of Chinese Opera: Two opera centers emerged Beijing and Yangzhou 300-400 forms of opera arose in
    10·1 answer
  • Understanding the link between education and your desired career is an integral part of your career _______.
    7·2 answers
  • Firewall implementation and design for an enterprise can be a daunting task. Choices made early in the design process can have b
    6·1 answer
  • You can click the ____ button to undo an automatic correction.
    9·1 answer
  • A recommended cleaner for the bowls of coffee brewers is
    7·1 answer
  • 4.8 code practice question 2
    10·1 answer
  • The central point of Christian belief is that God, the Father, entered into human history as the
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!