cleAndSphere.java // Step 1: Import the Scanner class for input import java.util.Scanner; /** * A Java program to calculate the circumference, area, * surface area, and volume based on an input radius. 1 3 4 5 Step 2: Enter your name for @author.and today's date for @version * @author () 8. 9. @version () */ public class CircleAndSphere { public static void main(String[] args) 10 11 12 13 14 15 // Step 3: Create a Scanner object to read input from the keyboard Scanner sc = new Scanner(System.in); 16 17 18 // Step 4: Display a prompt "Enter the radius: " // 19 and stay on the same line 20 System.out.print("Enter the radius"); 21 22 // Step 5: Read a double number for radius and 23 // store it in a variable 24 double radius = sc.nextDouble(); 25 26 // Step 6: Calculate the circumference using the input radius 27 // double result = 2*Math.PI * radius; and store it in a variable 28 29 30 31 // Step 7: Calculate the area using the input radius // double area = Math.PI* radius* radius; 32 and store it in a variable 33 34 35 // Step 8: Calculate the surface area using the input radius 36 // and store it in a variable 37

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Fix the code
rcleAndSphere.java
// Step 1: Import the Scanner class for input
import java.util.Scanner;
1
/**
* A Java program to calculate the circumference, area,
* surface area, and volume based on an input radius.
4
Step 2: Enter your name for @author.and today's date for @version
* @author
* @version ()
7
8.
10
*/
public class CircleAndSphere
{
public static void main(String[] args)
11
12
13
14
15
// Step 3: Create a Scanner object to read input from the keyboard
Scanner sc = new Scanner(System.in);
16
17
18
// Step 4: Display a prompt "Enter the radius: "
19
//
and stay on the same line
System.out.print("Enter the radius");
20
21
22
// Step 5: Read a double number for radius and
23
//
store it in a variable
24
double radius = sc.nextDouble();
25
26
// Step 6: Calculate the circumference using the input radius
27
//
double result = 2*Math. PI * radius;
and store it in a variable
28
29
30
31
// Step 7: Calculate the area using the input radius
32
//
and store it in a variable
33
double area = Math.PI* radius* radius;
34
35
// Step 8: Calculate the surface area using the input radius
//
36
and store it in a variable
37
Transcribed Image Text:rcleAndSphere.java // Step 1: Import the Scanner class for input import java.util.Scanner; 1 /** * A Java program to calculate the circumference, area, * surface area, and volume based on an input radius. 4 Step 2: Enter your name for @author.and today's date for @version * @author * @version () 7 8. 10 */ public class CircleAndSphere { public static void main(String[] args) 11 12 13 14 15 // Step 3: Create a Scanner object to read input from the keyboard Scanner sc = new Scanner(System.in); 16 17 18 // Step 4: Display a prompt "Enter the radius: " 19 // and stay on the same line System.out.print("Enter the radius"); 20 21 22 // Step 5: Read a double number for radius and 23 // store it in a variable 24 double radius = sc.nextDouble(); 25 26 // Step 6: Calculate the circumference using the input radius 27 // double result = 2*Math. PI * radius; and store it in a variable 28 29 30 31 // Step 7: Calculate the area using the input radius 32 // and store it in a variable 33 double area = Math.PI* radius* radius; 34 35 // Step 8: Calculate the surface area using the input radius // 36 and store it in a variable 37
// Step 7: Calculate the area using the input radius
and store it in a variable
//
double area = Math.PI* radius* radius;
4
// Step 8: Calculate the surface area using the input radius
and store it in a variable
//
double SurfaceArea = 4* area;
89*
// Step 9: Calculate the volume using the input radius
//
t
41
42
43
44
and store it in a variable
double volume = 4*Math.PI*Math.pow(radius,2);
// Step 10: Display the radius and calculated values
// Sample output for radius 5
// The radius: 5.0.
// The circle circumference: 31.41592653589793
// The circle area: 78.53981633974483
// The sphere surface area: 314.1592653589793
// The sphere volume: 523.5987755982989
System.out.println("The radius: "+radius);
System.out.println(" The circle circumference: " + circum);
System.out.println(" The circle area: "+area);
System.out.prinln(" The sphere surface are:" + sphere);
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
CodeCheck
Reset
Download
sting CircleAndSphere.java
Error:
Transcribed Image Text:// Step 7: Calculate the area using the input radius and store it in a variable // double area = Math.PI* radius* radius; 4 // Step 8: Calculate the surface area using the input radius and store it in a variable // double SurfaceArea = 4* area; 89* // Step 9: Calculate the volume using the input radius // t 41 42 43 44 and store it in a variable double volume = 4*Math.PI*Math.pow(radius,2); // Step 10: Display the radius and calculated values // Sample output for radius 5 // The radius: 5.0. // The circle circumference: 31.41592653589793 // The circle area: 78.53981633974483 // The sphere surface area: 314.1592653589793 // The sphere volume: 523.5987755982989 System.out.println("The radius: "+radius); System.out.println(" The circle circumference: " + circum); System.out.println(" The circle area: "+area); System.out.prinln(" The sphere surface are:" + sphere); 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 CodeCheck Reset Download sting CircleAndSphere.java Error:
Expert Solution
Step 1

CORRECTED PROGRAM CODE:

// Step 1: Import the Scanner class for input
import java.util.Scanner;
/*

* A Java program to calculate the circumference, area,

* surface area, and volume based on an input radius.
*
* Step 2: Enter your name for @author. and today's date for @version
* @author ()
* @version ()
*/
public class Main
{
    public static void main(String[] args)
    {
        // Step 3: Create a Scanner object to read input from the keyboard
        Scanner sc = new Scanner (System. in);
        // Step 4: Display a prompt "Enter the radius: "
        // and stay on the same line
        System.out.print("Enter the radius");
        // Step 5: Read a double number for radius and
        // store it in a variable
        double radius = sc.nextDouble();
        // Step 6: Calculate the circumference using the input radius
        // and store it in a variable
        double result = 2*Math.PI * radius;
        // Step 7: Calculate the area using the input radius
        // and store it in a variable
        double area = Math.PI* radius* radius;
        // Step 8: Calculate the surface area using the input radius
        // and store it in a variable
        double SurfaceArea = 4* area;
        // Step 9: Calculate the volume using the input radius
        // and store it in a variable
        double volume = 4*Math.PI*Math.pow(radius, 2);
        // Step 10: Display the radius and calculated values
        // Sample output for radius 5
        // The radius: 5.0
        // The circle circumference: 31.41592653589793
        // The circle area: 78:53981633974483
        // The sphere surface area: 314.1592653589793
        // The sphere volume: 523.5987755982989
        System. out.println("The radius: "+radius);
        System.out.println(" The circle circumference: " + result) ;
        System.out.println(" The circle area: "+area) ;
        System.out.println(" The sphere surface are:" + SurfaceArea) ;
    }
}

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education