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]
3 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]3 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
True or False?
Karo-lina-s [1.5K]

Answer:

The given statement is False

Explanation:

OSI or Open System Interconnection is a reference model around which the networks are built. OSI gives us all the information regarding movement of data from a software through physical means to another software. Generally it is used as a guidance tool. Seven layers combine to build an OSI model/

TCP/IP (Transmission control protocol/ Internet protocol) model is in a way implementation of the OSI model. It tells about the end-to-end transmission of data being transmitted using OSI model.

<h3>I hope it will help you! </h3>
5 0
3 years ago
Briefly explain the following terms and concepts:
morpeh [17]

Answer:

Answer below

Explanation:

Maximum transmission unit (MTU)

A maximum transmission unit (MTU) is the largest packet or frame size that is usually specified in Eight-bit bytes, which can be sent in a packet or frame-based network such as the internet.  

Longest Prefix Match

Longest prefix match is an algorithm used by routers in Internet Protocol to lookup the IP prefix that will likely be the terminal point of the next hop from the router.

CIDR and Subnet Mask

CIDR, known in full as Classless inter-domain routing, is a set of IP standards that is used to make customized identifiers for networks and individual devices.  

A subnet mask separates the internet protocol (IP) address into the network address and host address.

 

Switching Fabric

Switching fabric is simply an arrangement of the elements of a communication network also known as network topology, whereby the nodes of the network are seen to interconnect with one or more network switches.

7 0
3 years ago
Read 2 more answers
A(n) __________ DHCPv6 server relies on router advertisements to give some information to individual hosts, making small changes
vodomira [7]

Answer:

Stateless

Explanation:

According to my experience in the field of information technology and networking, I can say that the type of server being mentioned is a Stateless DHCPv6 server. This is a server that provides some information to individual hosts within the network, but does not make any address assignments to the individual devices. Like mentioned in the question.

8 0
2 years ago
Hi guts gyt edgsahgflefljwegfwygafbhdshdnvcashD
lapo4ka [179]

Hello, how are you and welcome!

4 0
3 years ago
Which document would most likely be written in an informal style?
Masteriza [31]

Answer:

An advertisement for sportswear

Explanation:

An advertisement for sportswear would most likely be written in an informal style.

6 0
3 years ago
Other questions:
  • Which of the following are true statements about collisions in hashing? Linear probing can cause secondary collisions. Higher sp
    6·1 answer
  • A user can easily move to the end of a document by pressing the _____ key combination.
    10·2 answers
  • At the coffee shop where they work, Jen is the safety officer, Richard is in charge of administering first aid, Ashley is respon
    13·2 answers
  • The Springfork Amateur Golf Club has a tournament every weekend. The club president
    7·1 answer
  • If there is a circuit that is being used 36 CCS then how much of that circuit is being used in Erlang?
    8·1 answer
  • The computer program that Josh is working on presents him with a sentence in which a word has been underlined. Josh has to indic
    9·1 answer
  • What is a main cause of an aurora?
    8·1 answer
  • Please help me with opinions, ideas, any websites that would help, or chart, article, video, or podcast to help support your pos
    10·1 answer
  • Please please help I don’t understand this
    6·1 answer
  • [80 points] Fill in the missing word.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!