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
wel
3 years ago
14

Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative intege

rs as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Ex: If the input is: 15 20 0 5 -1 the output is: 10 20
Mathematics
1 answer:
Gnesinka [82]3 years ago
7 0

Answer:

Step-by-step explanation:

import java.util.Scanner;

public class LabProgram

{

  public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);//to read input

  int count=0;//to keep track of the count of numbers entered

  int max=0;//to store the maximum value

  int sum=0;//to store the sum of numbers entered

  double av=0;//to calculate and store the average

  //reading inputs until a negative number is entered

  while(true)

  {

  int n = sc.nextInt();//reading input

  if(n<0)//if negative number

  break;//then stopping loop

  count++;//increasing count

  if(count==1)//means it is first number

  max=n;

  else if(max<n)//if current number is greater than previous max

  max=n;//updating max

  sum+=n;//adding new number to sum

  }

  //finding average

  av = (double)sum/count;

  //displaying output

      System.out.println((int)av+" "+max);//remove type casting (int) here, if you want decimal places also

  }

}

output:

15 20 0 5 -1

10 20

You might be interested in
Todos los numeros naturales son enteros​
Mamont248 [21]
Pee brain. . .you get it okay
7 0
3 years ago
Read 2 more answers
What is <br> Sinx =125/500
Anastasy [175]

Answer:

14.4775121859299

Step-by-step explanation:

sinx = 125/500

sinx = 1/4

or, x = arcsin(1/4)

5 0
3 years ago
If you drove 60 miles in two hours, how many miles per hour did you drive?<br><br> 30 miles per hour
soldi70 [24.7K]

Answer:

30 mph

Step-by-step explanation:

6 0
3 years ago
Read 2 more answers
Suppose you are buying orange juice and you want to find the best deal. You find four different brands that offer various sizes
Alenkinab [10]

Answer: 3rd brand.

Step-by-step explanation:

1st brand:

6 oz cost $1.25

The amount per ounce will be:

= $1.25/6

= $0.21

2nd brand:

8 oz cost $1.33

The amount per ounce will be:

= $1.33/8

= $0.17

3rd brand:

12 oz cost $1.50

The amount per ounce will be:

= $1.50/12

= $0.125

4th brand:

16 oz cost $2.10

The amount per ounce will be:

= $2.10/16

= $0.13

From the calculation, the 3rd brand of orange juice is the better but as it's cheaper than others.

7 0
3 years ago
=
svet-max [94.6K]

Answer:

The polygon has 9 sides

Step-by-step explanation:

we know that

A regular polygon has equal length sides and equal interior angles

step 1

Find the measure of the interior angle

Remember that

The interior angle plus the exterior angle must be equal to 180 degrees (form a linear pair)

Let

x ----> the measure of each interior angle in the regular polygon

so

x+40^o=180^o

solve for x

x=180^o-40^o=140^o

step 2

Find the number of sides of the regular polygon

we know that

The measure of each interior angle in a regular polygon is given by the formula

x=\frac{(n-2)180^o}{n}

where

n is the number of sides of the polygon

substitute the given values

140^o=\frac{(n-2)180^o}{n}

solve for n

140n=180n-360\\180n-140n=360\\40n=360\\n=9\ sides

therefore

The polygon has 9 sides

8 0
3 years ago
Other questions:
  • I need help please for trigonometry finding ratios
    8·1 answer
  • What is a rational number
    12·1 answer
  • <img src="https://tex.z-dn.net/?f=%20%5Cfrac%7B%28a-3%29%20%2A%20%28%5Cfrac%7Ba%7D%7B3%7D%20%2B1%29%7D%7B%5Cfrac%7B1%7D%7B3%7D%7
    6·1 answer
  • The age of a father is 2 less than 7 times the age of his son. In 3 years, the shn kf their ages will be 52. If the sons present
    15·1 answer
  • Find f(-5) f(x) -4x + 3
    15·1 answer
  • Question 2<br> What is the y-intercept in the equation y = 4x - 3?<br> 4<br> 0<br> 3
    7·1 answer
  • Juan bought "g" video games for $35 each. Which expression represents how much he spent on the games?
    10·1 answer
  • I paid $125 for Pokémon cards and sold for $150. What is the percentage of mark up rate.
    10·1 answer
  • In this problem you will use undetermined coefficients to solve the nonhomogeneous equation y′′+4y′+3y=8te^−t+6e^−t−(9t+6)
    7·1 answer
  • What are three solutions of the inequality 29x+4&lt;76?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!