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]
3 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]3 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
Here is what my rob-lox user USED to look like, btw what is better, Samsung or apple?
____ [38]
Apple is better then Samsung
6 0
2 years ago
Read 2 more answers
In Java an abstract class cannot be sub-classed<br><br> ?? True<br><br> ?? False
mojhsa [17]

Answer:

False

Explanation:

An abstract class is a class declared abstract — it may or may not include abstract techniques. It is not possible to instantiate abstract classes, but they can be sub-classed.

<u></u>

<u>Abstract method declaration</u>

             

         abstract void moveTo(double X, double Y);

Usually the subclass offers solutions for all of the abstract techniques in its parent class when an abstract class is sub-classed. If not, however, the subclass must be declared abstract as well.

<u>Example</u>

public abstract class GraphicObject {

  // declaring fields

  // declaring non-abstract methods

  abstract void draw();

}

8 0
3 years ago
POINT BOOST:
stiv31 [10]

glenn

she's good what's your

8 0
2 years ago
Visit the target Let Me Discover page and review the history of HTML. Also, search the internet for the history of the internet
Lyrx [107]

Whether you are a novice, hoping to delve into the world of web design or an experienced webmaster keen to improve your skills, we’ve got online tutorials tailored to your web design needs.


Our HTML For Absolute Beginners will turn you from wannabe to webmaster in just a few hours. Unlike many other HTML tutorials, it's a step-by-step guide – not a boring long-winded reference.


Our step-by-step guide teaches you the basics of HTML and how to build your first website. That means how to layout an HTML page, how to add text and images, how to add headings and text formatting, and how to use tables.

use this because that is cheating no offence

3 0
3 years ago
What are the steps to apply new layout to the slide. ( Write in easy way)​
pogonyaev

Answer:

Explanation:

Apply a slide layout

1 . Select the slide that you want to change the layout for.

2 . Select Home > Layout.

3 . Select the layout that you want. The layouts contain placeholders for text, videos, pictures, charts, shapes, clip art, a background, and more. The layouts also contain the formatting for those objects, like theme colors, fonts, and effects

5 0
3 years ago
Other questions:
  • An important safety precaution you should take before starting any electrical servicing job is to make sure that your
    15·2 answers
  • Why Unicode is the standard way of converting binary to text?
    8·1 answer
  • A work-study student receives a paycheck from:
    15·2 answers
  • The function of the __________ is to on transmission assemble data into a frame, on reception disassemble frame and perform addr
    8·1 answer
  • You want to make sure that a set of servers only accepts traffic for specific network services. You have verified that the serve
    7·1 answer
  • Which of the following is true of a procedure? Check all that apply.
    10·2 answers
  • 50 POINTS How do you express yourself and your creativity through computer science?
    12·1 answer
  • If the starting address location changes, in which of the following cases, the program has to be recompiled? Select one: a. Both
    12·1 answer
  • A. A set of electronic program that makes of computer perform tasks
    11·1 answer
  • (Synchronized threads) Write a program that launches 1000 threads. Each thread adds a random integer (ranging from 1 to 3, inclu
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!