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
Which option is NOT in the Link to portion of the Insert Hyperlink dialog box?
WARRIOR [948]
Existing file or webpage
4 0
4 years ago
Read 2 more answers
What type of information is appropriate for headers and footers? Check all that apply.
lbvjy [14]

Answer:

slide/page number

smart art

maybe date and time

Explanation:

6 0
3 years ago
Read 2 more answers
Match the cell reference to its definition,
Anna35 [415]

Answer:

Absolute reference- the cell remains constant when copied or moved

Relative reference- the cell changes based on the position of rows and columns

Mixed references- the cell has combination of two other types of cell references

Explanation:

4 0
2 years ago
A host is on the 192.168.146.0 network that has a subnet mask of 255.255.255.0. The binary value of the host portion is 11010101
QveST [7]

Answer:

213

Explanation:

The given parameters are;

The network on which the host is on = 192.168.146.0

The subnet mast = 255.255.255.0

The binary value of the host portion = 11010101

To convert the binary value to decimal value, we proceed by multiplying each of the digits of the binary value by the corresponding power of 2, from the left to right, starting from a power of 0, and sum the result, as follows;

(11010101)₂ = (1×2⁷ + 1×2⁶ + 0×2⁵ + 1×2⁴ + 0×2³ + 1×2² + 0×2¹ + 1×2⁰)₁₀

1×2⁷+1×2⁶+0×2⁵+1×2⁴+0×2³+1×2²+0×2¹+1×2⁰= 128+64+0+16+4+1 = 213

∴ (11010101)₂ = (213)₁₀

The decimal value of 11010101 is 213.

8 0
4 years ago
What is the best thing about Tuesday’s in general? Why?
Stolb23 [73]

Answer:

tbh I really don't know what you mean

4 0
4 years ago
Other questions:
  • Which of the following can be sources of sediment? A. fragments of other rocks B. chemicals and minerals dissolved in water C. s
    11·1 answer
  • A network administrator receives a call from the sales department requesting ports 20 and 21 be opened on the company’s firewall
    12·1 answer
  • This term describes two or more arrays that hold related data, and the related elements in each array are accessed with a common
    15·1 answer
  • 6.
    13·1 answer
  • Why are laptops usually more expensive than desktop computers with comparable power and features?
    10·1 answer
  • Write down the complete AJAX code to avoid page caching.
    6·1 answer
  • A<br> is a reduced-size version of a graphic image used to help recognize and organize pictures.
    5·1 answer
  • The Spanning Tree Protocol operates at the Network layer of the OSI model.
    13·1 answer
  • Difference between a lesson plan and scheme of work​
    6·2 answers
  • What type pf physical security devices lets a company locate devices that have been moved to a new location?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!