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
Ludmilka [50]
3 years ago
5

Create a new Java application called "AverageCalculator" (without the quotation marks) that prompts the user with three separate

prompts for three numbers (use double values for these), computes the average of those three doubles (use a double for the average), and then prints out explanatory text, the three numbers, and their average, printed with 2 decimal places.For example, if the user gives your program the numbers 30, 100, and 21, your output should look very much like the following: The average of the numbers 30.00, 100.00, and 21.00 is 50.33.
Computers and Technology
1 answer:
k0ka [10]3 years ago
4 0
<h2>Answer:</h2>

//import the Scanner class

import java.util.Scanner;

public class AverageCalculator {

   public static void main(String[] args) {

       //Create an object of the Scanner class to allow for user's input

       Scanner input = new Scanner(System.in);

       

       //Create first prompt for the user to enter the first number

       System.out.println("Please enter the first number");

       

       //Use the Scanner object input, to receive the first number

       //And store in a double variable called fnum

       double fnum = input.nextDouble();

       

       //Create second prompt for the user to enter the second number

       System.out.println("Please enter the second number");

       

       //Use the Scanner object input, to receive the second number

       //And store in a double variable called snum

       double snum = input.nextDouble();

       

       //Create third prompt for the user to enter the third number

       System.out.println("Please enter the third number");

       

       //Use the Scanner object input, to receive the third number

       //And store in a double variable called tnum

       double tnum = input.nextDouble();

       

       //Declare a variable of type double, called avg, to hold the average of the three numbers

       double avg;

       

       //Now find the average of the three numbers,

       // and store the result of the average in the avg variable declared above

       avg = (fnum + snum + tnum) / 3;

               

       //Print out the result with explanatory text while you convert

       //all numbers to 2 decimal places by using the String.format() method.

       //The String.format() method takes in two arguments - the format descriptor and  

       //the number to be transformed.

       //First argument : In this case, the format descriptor is %.2f

       //Where the % sign signifies that the string (%.2f) is a format specifier.

       //The .2 specifies 2 decimal places. It means, you would use .3 if you wanted the number in 3 decimal places.

       //The f signifies that the number in question is a floating-point number.

       //Second argument : specifies the floating-point number to be transformed.        

       System.out.println("The average of the numbers " + String.format("%.2f", fnum) + ", " + String.format("%.2f", snum) + ", and " + String.format("%.2f", tnum) + " is " + String.format("%.2f", avg));

   

}      //End of main method

   

}   // End of class declaration

<h2>Sample output:</h2><h2>---------------------------------------------------------------</h2>

>> Please enter the first number

30

>> Please enter the second number

100

>> Please enter the third number

21

>> The average of the numbers 30.00, 100.00, and 21.00 is 50.33

<h2>---------------------------------------------------------------</h2>

<h2>Explanation:</h2>

The code above has been written in Java and it contains comments explaining every segment of the code. Please go through the comments carefully for more understanding.

<h2>Code without comments:</h2><h2 />

import java.util.Scanner;

public class AverageCalculator {

   public static void main(String[] args) {  

       Scanner input = new Scanner(System.in);

       System.out.println("Please enter the first number");

       double fnum = input.nextDouble();

       System.out.println("Please enter the second number");

       double snum = input.nextDouble();

     

       System.out.println("Please enter the third number");        

       double tnum = input.nextDouble();

     

       double avg;

       avg = (fnum + snum + tnum) / 3;

               

       System.out.println("The average of the numbers " + String.format("%.2f", fnum) + ", " + String.format("%.2f", snum) + ", and " + String.format("%.2f", tnum) + " is " + String.format("%.2f", avg));

   

}  

   

}

You might be interested in
Brooke is trying to save enough money in the next fifteen months to purchase a plane ticket to Australia. Every month Brooke sav
ankoles [38]

Answer:

3000

Explanation:

8 0
3 years ago
Some file formats are specific to the program that uses them and the operating system on which they are used. True or False
mina [271]

Answer:

true

Explanation:

certain file formats can only be used to it's own operating system

5 0
4 years ago
Read 2 more answers
You have a small business.Due to the recent pandemic you seem to be losing contacts with your suppliers and customers.You want t
Brilliant_brown [7]

Answer:

You can use social media to advertise your product or service you don’t need to work to pay your employees insted create content as a way to help your business grow/expand.

Explanation:

Social media is a big platform and you can eventually find new potential clients and you can benefit yourself instead of paying someone

8 0
3 years ago
What is the best summation of the main idea in Andrew Blum’s speech, "Discover the Physical Side of the Internet"? Question 10 o
rewona [7]

Answer:

c) We should be aware of the network and geographic presence behind our internet access rather than taking it for granted.

Explanation:

Andrew Blum’s speech is about the physical world and the size of the internet, he spent more time on the computer and cell phone than in the real world, and he had an issue with his internet, and the technician told him, squirrel has bittern your internet.

This can mean that the internet can be something complex and a huge thing, but can be damage for a squirrel, can be something simple.

6 0
3 years ago
Could you describe in 3 lines what an API is?
Brilliant_brown [7]

An API is in computer programming. So it is an application programming interface is a set of several subroutine definitions. Also consists of Communication protocols and tools for you to build software.

Also known by its full names, Application Programming Interface. I was just going to ask it myself actually.

I hope this helps and good question?

8 0
4 years ago
Other questions:
  • Smartphones store their operating system software in ________.
    11·1 answer
  • The most significant factor in choosing a transmission method is its ____.
    10·1 answer
  • You receive a file named Project4.xlsx as an attachment to an email message. What do you expect the file to contain?
    8·1 answer
  • Which of these should most likely be included in a wire frame ?
    12·1 answer
  • What is cyber stalking and how does it work?
    7·2 answers
  • The actual database of Active Directory shared resources is stored on one or more computers designated as:
    6·1 answer
  • How does a computer work
    13·1 answer
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to find the minimum age of a
    5·2 answers
  • Please help i will give you brainlest!!!!!!!!!
    6·1 answer
  • How to download film​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!