Question: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then, create

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then, 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. (See Horstmann, Section 2.3.2, pp. 50-52 for some ideas.) 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. For this and all upcoming PA's involving user input, use a Scanner class-created object to capture input. Do not use a command (terminal) prompt.

I've copied and pasted my code below, and I'm using Netbeans IDE, but it's taking a super long time even run the code I've pasted below, so I can't even see if there's any errors. I know from previous experience that it's never taken this long, does this mean there's already a mistake? Thanks in advance!

import java.util.Scanner; import java.text.DecimalFormat; public class AverageCalculator {

/** * * */

/** * @param args the command line arguments */ public static void main(String[] args) {

Scanner in = new Scanner(System.in); String a; String b; String c; String d; double avg; System.out.print("Input the first number: "); double x = in.nextDouble();

System.out.print("Input the second number: "); double y = in.nextDouble(); System.out.print("Input the third number: "); double z = in.nextDouble();

DecimalFormat df = new DecimalFormat("####0.00"); a=df.format(x); b=df.format(y); c=df.format(z); avg=average(x, y, z); d=df.format(avg); System.out.print("The average of numbers "+ a+" "+ b+" "+ c+" "+ "is " +d+" " );

}

public static double average(double x,double y,double z) { return (x+y+z) / 3;

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!