Run the following program: import java.util.Scanner; /** Project1.java by */ public class Project1 { public static void main(String[] args) { final double PI = 3.1428; Scanner keyboard = new...


Run the following program:


import java.util.Scanner;


/** Project1.java by


*/


public class Project1


{


public static void main(String[] args)


{


final double PI = 3.1428;


Scanner keyboard = new Scanner(System.in);


System.out.print("Think of a planet and enter its + "radius in miles: ");


double radius = keyboard.nextDouble();


double volume = 4.0 * PI * radius * radius * radius / 3.0;


double earthVolume = 4.0 * PI * 3963 * 3963 * 3963 / 3.0;


double proportion = volume / earthVolume;


System.out.println();


System.out.println("Your planet has a radius of " + radius +" miles");


System.out.println("and has a volume of " + volume + " cubic miles.");


System.out.println("This volume is " + proportion + " times the earth's volume.");


} // end main


} // end Project1


Now make the following changes to the program and run it again:


• Add comments to the program to make it more readable.


• The value of the constant PI is incorrect. Correct this value rounded to four decimal places.


• Replace the unnamed constant 3963 with a named constant. It represents the earth’s radius in miles.


• Compute the surface area of the planet and display it. The surface area of a sphere of radius r is 4 π r2.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here