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
Vladimir [108]
3 years ago
7

Write a program that prompts the user to enter positive integers (as many as the user enters) from standard input and prints out

the maximum and minimum values.Here is an example of how your program should behave.Enter a positive integer: 2 Enter a positive integer: 9 Enter a positive integer: 3 Enter a positive integer:-1 The maximum integer is 9 and minimum is 2. Note: • Zero: 'O' is not a positive integer. • You must include code to deal with any exceptions that may arise in your program. • Insert 'import' statement(s) at the beginning • Copy the entire class, including the public static main method, 1 import java.util.*; 2 public class Ex0603 { 3 public static void main(String[] args) { 4 Scanner in = new Scanner(System.in); 5Write a program that prompts the user to enter an integer N, then reads N double values, and prints their mean (average value) and sample standard deviation (square root of the sum of the squares of their differences from the average, divided by N-1). Enter an integer: 5 Enter a number: 1 Enter a number: 2 Enter a number: 3 Enter a number: 4 Enter a number: 5 Average value is: 3.00 and the standard deviation is: 1.58 Note: • You must include code to deal with any exceptions that may arise in your program • Write the entire program in the answer box below. For example: Input Result 5 Enter an integer: Enter a number: Enter a number: Enter a number: Enter a number: Enter a number: Average value is: 3.00 and the standard d eviation is: 1.58 123452 Enter an integer: Enter a number: Enter a number: Invalid input!1b

Computers and Technology
1 answer:
julia-pushkina [17]3 years ago
7 0

Answer:

Here is the JAVA program that prompts the user to enter positive integers from standard input and prints out the maximum and minimum values:

import java.util.*;

public class Ex0603 {

   public static void main(String[] args) { //start of main function

   Scanner in = new Scanner(System.in); //creates Scanner class object to take input from user

   int minimum = 0; //stores the minimum of the integers

   int maximum = 0; //stores the minimum of the integers

   int num; //stores the positive integer values

   System.out.println("enter a positive integer: ");//prompts user to enter a positive integer

   num = in.nextInt();//scans and reads the input integer value from user

   minimum = num;  //assigns value of num to minimum

   while(true) {//while loop keeps prompting user to enter a positive integer

       System.out.println("enter a positive integer: ");//prompts user to enter a positive integer

       num = in.nextInt();//scans and reads the input integer value from user

       if(num <=0)//if the user inputs a negative integer or 0

           break; //breaks the loop

       if (num > maximum) {//if the value of positive integer is greater than the maximum of value

           maximum = num; } //assigns that maximum value of num to maximum variable

       if (num < minimum) {//if the value of positive integer is less than the minimum of value

           minimum = num; //assigns that minimum value of num to minimum       }    }            

   System.out.println("The maximum integer is : " + maximum); //displays the maximum of the positive integers

   System.out.println("The minimum integer is : " + minimum); }}   //displays the minimum of the positive integers

Explanation:

Here is the JAVA program that that prompts the user to enter an integer N, then reads N double values, and prints their mean (average value) and sample standard deviation:

import java.util.*;  

public class Ex0603 {  

public static void main(String[] args) { //start of main function

Scanner in = new Scanner(System.in);  //creates Scanner class object to take input from user

double integer= 0;  //to store the number of input values

double sum = 0;  //to store the sum of input numbers

double mean = 0;  //to store the average of numbers

double sd = 0;  //to store the standard deviation result

double variance = 0;  //to store the variance result

double sumSquare = 0;  //to store the sum of (num-mean)^2

int n = 0;  //to store the sample size N

   System.out.println("Enter an integer: ");  //prompts user to enter an integer that is how many elements user wants to input

   integer = in.nextInt();  //reads the value of integer from user

   double size=integer; // declares a double type variable and assigns value of int type variable integer to this double type variable size

   int i=0;  //used to point each element of the num array

   double num[] = new double[(int)size];  //declares an array to hold the numbers input by user

   while(integer>0){  //loop executes until value of integer is greater than 0

   System.out.println("Enter a number: "); // prompts to enter a number

   num[i] = in.nextDouble(); //reads double values

   sum += num[i];  //adds the values stored in num array

   i++;  //increments i to point to the next element in num array

   n++;  //increments n to count the total number of elements

  integer--; //decrements integer value at each iteration

   mean = sum / n;    }  //compute the average of values

   i=0;  

    while(size>0){  //loop executes until value of size exceeds 0

       sumSquare += Math.pow(num[i]-mean,2); //takes the sum of square difference between each element of num array and value of mean

       i++; //increments i

      size--;   }  //decrements size

variance = sumSquare / (n-1);  //compute variance by dividing the result of sum of the squares of their differences from the mean by n-1

   sd = Math.sqrt(variance);  //computes standard deviation by using sqrt function which takes the sqrt of the result of variance computed above

System.out.println("Average value is: " + mean+ " and the standard deviation is " + String. format("%.2f", sd));   }} //displays the average of numbers stored in mean variable and value of standard deviation is displayed up to 2 decimal places

Screenshots of both programs and their outputs is attached.

You might be interested in
What does the action tool allow you to do in Microsoft Powerpoint?
12345 [234]

B.  Add actions , such as fly ins , between slide


8 0
3 years ago
Examples of ________, which is hosted on a web site, include e-mail, word processing, tax preparation, and game programs.
Keith_Richards [23]

Answer:Web Application

Explanation:Web hosting is more or less like having an ordinary computer in the cloud in order share information and resources with others world wide.One cannot make effective use of a computer without software applications . Similarly hosting just normal html pages and documents on a server cannot help increase productivity,hence the creation of cloud computer applications also known as "Web Apps (Web Applications)" to aid boost productivity and information dissemination via quality task automations.

4 0
2 years ago
⦁ Consider transferring an enormous file of L bytes from Host A to Host B. Assume an MSS of 536 bytes. ⦁ What is the maximum val
timurjin [86]

Answer:

a)  There are approximately  2^32 = 4,294,967,296 possible number of the sequence. This number of the sequence does not increase by one with every number of sequences but by byte number of data transferred. Therefore, the MSS size is insignificant. Thus, it can be inferred that the maximum L value is representable by 2^32 ≈ 4.19 Gbytes.

b)  ceil(2^32 / 536) = 8,012,999

The segment number is 66 bytes of header joined to every segment to get a cumulative sum of 528,857,934 bytes of header. Therefore, overall number of bytes sent will be 2^32 + 528,857,934 =  4.824 × 10^9 bytes.  Thus, we can conclude that the total time taken to send the file will be 249 seconds over a 155~Mbps link.

Explanation:

a)  There are approximately  2^32 = 4,294,967,296 possible number of the sequence. This number of the sequence does not increase by one with every number of sequences but by byte number of data transferred. Therefore, the MSS size is insignificant. Thus, it can be inferred that the maximum L value is representable by 2^32 ≈ 4.19 Gbytes.

b)  ceil(2^32 / 536) = 8,012,999

The segment number is 66 bytes of header joined to every segment to get a cumulative sum of 528,857,934 bytes of header. Therefore, overall number of bytes sent will be 2^32 + 528,857,934 =  4.824 × 10^9 bytes.  Thus, we can conclude that the total time taken to send the file will be 249 seconds over a 155~Mbps link.

8 0
2 years ago
To navigate to a new web page for which you know the url, type that url in the browser’s ____ bar and press enter.
Slav-nsk [51]
It would be to type the url in the browser's address bar
3 0
3 years ago
you are a new lenovo service provider and need to use the recovery utility information on the lenovo support website. this infor
yawa3891 [41]

Based on the above, the person that  you  should contact to request a service provider user id and password is Regional leads

<h3>Who is a Regional leads?</h3>

The stores, merchandise, and general presence of the company in a given region are managed by region leaders. They make sure the objectives are achieved. If not, they come up with plans to achieve the goals. Leaders in a region are expected to comprehend both the local economy and its historical context.

A regional lead is a manager, educator, or administrator who is in charge of finding and supporting workforce champions within organizations within their assigned region. Hence, he or she is the best person for you to contact.

Learn more about Region from

brainly.com/question/2001834
#SPJ1

8 0
1 year ago
Other questions:
  • Which forensics tool would you use to reveal recent pages viewed via the internet explorer browser?
    10·1 answer
  • A ________ restricts the number of a certain type of product that can be imported into a country.
    5·1 answer
  • Write a program that accepts 5 number and arrange them in ascending order​
    7·1 answer
  • Which part is the author’s address?
    5·1 answer
  • As you type your outline, click Demote to move a line of text
    13·2 answers
  • How to wire two separate switches &amp; lights using the same power source?
    14·1 answer
  • The two major types of system software programs are utility programs and the ________. Select one: A. user interface B. supervis
    13·1 answer
  • Any computer expert to help me answer this question.. am giving brainliest
    13·1 answer
  • Which Operating System is used most often in households?
    6·2 answers
  • Can someone make me a natural selection comic but only 5 same thing in the example pic but draw the animal different and a diffe
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!