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
Aleks [24]
4 years ago
12

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

gers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Ex: When the input is:
Computers and Technology
1 answer:
AnnZ [28]4 years ago
6 0

Answer:

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

  }

}

You might be interested in
Explain the derived data types in C language with examples each
IRISSAK [1]

Answer:

Array, pointers, struct, and union are the derived data types.

7 0
3 years ago
Hello safiya77 this is for you
Ray Of Light [21]
Hello astropiggy!
Feel free to ask any question!
I’ll try my best to answer them!
5 0
2 years ago
Which sentence best describes a story's rising action?
MAXImum [283]

Answer:

So first off I’m pretty sure you meant ELA class, but I will still answer the question for you. The sentence that best describes a stories rising action is when it describes the conflicts that lead to the climax of the story. The climax is the main point in a story, and usually towards the middle. (Even though this can vary in book series)

Explanation:

Rising action takes place in a book right before the climax, the main point. This really matter because they have to work it up to the climax. Think of it like a graph. The line won’t just shoot up, it will gradually go up, then gradually go down.

Hope this helped!!

6 0
3 years ago
How many times faster is a computer that measures at
jekas [21]

well Its something soooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

6 0
2 years ago
At what point in a vulnerability assessment would an attack tree be utilized?
ella [17]
During threat evaluation - A vulnerability assessment is done to gauge the impact expected from a successful attack and also how vulnerable the software is to an attack. An attack tree, when created during the threat evaluation phase allows one to analyze and describe possible attacks that can be realized on the system.
6 0
3 years ago
Other questions:
  • 1. What are the biggest risks when using the public Internet as a Wide Area Network (WAN) or transport for remote access to your
    6·1 answer
  • Discuss the importance of employee security awareness training. What innovative ways should company’s implement security trainin
    14·1 answer
  • 4-One possible performance multiplication enhancement is to do a shift and add instead of an actual multiplication. Since 9 * 6,
    12·1 answer
  • What does a spam e-mail normally promise you?
    9·1 answer
  • A company operates on two types of servers: 2 large servers (L) and 4 smaller servers (S), with a combined total of 64GB RAM. Th
    9·1 answer
  • This finding maximum number function will keep on going until we reach at the last value
    12·1 answer
  • Please could you help me
    6·2 answers
  • A user logs in to a virtual world and creates an animated character representing themselves, which they then use to move through
    15·2 answers
  • Use the svd() function in matlab to compute a, the rank-1 approximation of a. clearly state what a, is, rounded to 4 decimal pla
    15·1 answer
  • Write an answer in three to five sentences that describes the photo, explains what better lighting would mean for your photograp
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!