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
Why is weather forecast so important for hang gliders?
professor190 [17]
Well, it wouldn't be such a good idea if they got caught up in a storm, would it? :p

Strong winds could blow them off-course, or even lightning has a chance of striking the hand glider, causing damage to the glider, the person, or even both.

Additionally, a weather forecast can help in my generic situations. For example, knowing whether to wrap up warm for cold weather, or wear something a bit more loose and breathable for hot weather.
6 0
3 years ago
What type of bus does PCI use?
Vera_Pavlovna [14]

Answer:

PCI uses a 32-bit or 64-bit parallel bus.

8 0
2 years ago
1. Add the following method to the Point class:
Pachacha [2.7K]

Answer:

Explanation:

The following code is written in Java and creates all of the methods that were requested in the question. There is no main method in any of these classes so they will have to be called from the main method and call one of the objects created method for the code to be tested. (I have tested it and it is working perfectly.)

class Point {

   private int x, y;

   public void Point(int x, int y) {

       this.x = x;

       this.y = y;

   }

   public double distance (Point other) {

      double distance = Math.sqrt(Math.pow((other.x - this.x), 2) + Math.pow((other.y - this.y), 2));

      return distance;

   }

   

   public int quadrant() {

       if (this.x > 0 && this.y > 0) {

           return 1;

       } else if (this.x < 0 && this.y > 0) {

           return 2;

       } else if (this.x < 0 && this.y < 0) {

           return 3;

       } else if (this.x > 0 && this.y < 0) {

           return 4;

       } else {

           return 0;

       }

   }

}

class Name {

   String firstName, lastName;

   char middleInitial;

   

   public String getNormalOrder() {

       String fullName = firstName + " " + middleInitial + " " + lastName;

       return fullName;

   }

   

   public String getReverseOrder() {

       String fullName = lastName + ", " + firstName + " " + middleInitial;

       return fullName;

   }

}

4 0
2 years ago
When an array is passed to a function, it is actually ________ the array that is/are passed?
MAVERICK [17]
Hello <span>MrSnuffleBuns4243 
</span>

Answer: When an array is passed to a function, it is actually  <span>the starting memory address of </span>the array that is/are passed?

Hope this helps
-Chris
5 0
3 years ago
What is the hexadecimal equivalent for 11000101?
Makovka662 [10]

Answer: C5₁₆ ⇔ 11000101₂ ⇔ 197⏨

Explanation: 11000101 is a binary number

it's equivalent decimal number is

1x2⁷+ 1x2⁶+0x2⁵ + 0x2⁴+0x2³+1x2²+0x2¹+1x2⁰ = 128+64+4+1 = 197

Hexadecimal system has equivalents in decimal system

0 ⇔0

1 ⇔ 1

2 ⇔ 2

3 ⇔ 3

4 ⇔ 4

5 ⇔ 5

6 ⇔ 6

7 ⇔ 7

8 ⇔ 8

9 ⇔ 9

10 ⇔A

11 ⇔B

12 ⇔C

13 ⇔D

14 ⇔E

15 ⇔F

197 ⇔??

To convert this decimal number in a hexadecimal number we have to divide it by 16

197/16

12,...

the quotient without the decimal part is multiplied by 16 and subtracted from the number

12x16 = 192

197-192 = 5

Then this number can be expressed as 12x16¹ + 5x16⁰ = 192 + 5 = 197

But in the hexadecimal system there are not digits > 9 , so 12 ⇔ C

197⏨ = Cx16¹ + 5x16⁰ = C5₁₆

Answer: C5₁₆ ⇔ 11000101₂ ⇔ 197⏨

\textit{\textbf{Spymore}}

8 0
3 years ago
Other questions:
  • Custom parameters 1, 2 and 3 provide the same end value for all keywords. true or false?
    14·1 answer
  • Your bank contacts you asking you to phone a number supplied in the email.What do you?
    13·2 answers
  • What is a block cipher algorithm that operates on 64-bit blocks and can have a key length from 32 to 448 bits?
    8·1 answer
  • Steps to log out of an email account ​
    5·2 answers
  • What is the type of person of personal computer which is also called a laptop computer?
    8·1 answer
  • You have the templates of 2 classes, Person and Program. The Person class has 4 attributes, name, age, major and gpa. There is a
    7·1 answer
  • Which of the following accessories would you use to create a drawing? A. Calculator B. Notepad C. Paint D. WordPad
    14·2 answers
  • Language modeling incorporates rules of __. Select all that apply.
    7·1 answer
  • Computer system with a 32-bit logical address and 4k-byte page size. assume that each entry of a page table consists of 4bytes.
    6·1 answer
  • A multiprocessor with 10 processors has 36 attached tape drives. A number of jobs have been submitted to the system where each j
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!