Create a Scanner object to read input from the keyboard new Scanner(System in):

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
11 public class CircleAndSphere
12
13
public static void main(String[] args)
14
// Step 3: Create a Scanner object to read input from the keyboard
Scanner sc = new Scanner(System.in);
15
16
17
// Step 4: Display a prompt "Enter the radius: "
//
18
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
//
double radius = sc.nextDouble();
24
25
26
// Step 6: Calculate the circumference using the input radius
//
double result = 2*Math.PI * radius;
27
and store it in a variable
28
29
30
// Step 7: Calculate the area using the input radius
//
double area = Math.PI* radius* radius;
31
32
and store it in à variable
33
34
35
36
// Step 8: Calculate the surface area using the input radius
and store it in a variable
//
37
38
double SurfaceArea = 4* area;
39
// Step 9: Calculate the volume using the input radius
40
//
and store it in a variable
41
double volume = 4*Math.PI*Math.pow(radius,5);
// Step 10: Display the radius and calculated values
// Sample output for radius 5
// The radius: 5.0
System.out.println("The radius: "+radius);
// The circle circumfer
System.out.println("The circle circumference: " +result);
42
43
44
45
46
47
31.41
48
esc
F1
F2
F3
F4
E5
F6
@
#
$
%
&
Transcribed Image Text:11 public class CircleAndSphere 12 13 public static void main(String[] args) 14 // Step 3: Create a Scanner object to read input from the keyboard Scanner sc = new Scanner(System.in); 15 16 17 // Step 4: Display a prompt "Enter the radius: " // 18 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 // double radius = sc.nextDouble(); 24 25 26 // Step 6: Calculate the circumference using the input radius // double result = 2*Math.PI * radius; 27 and store it in a variable 28 29 30 // Step 7: Calculate the area using the input radius // double area = Math.PI* radius* radius; 31 32 and store it in à variable 33 34 35 36 // Step 8: Calculate the surface area using the input radius and store it in a variable // 37 38 double SurfaceArea = 4* area; 39 // Step 9: Calculate the volume using the input radius 40 // and store it in a variable 41 double volume = 4*Math.PI*Math.pow(radius,5); // Step 10: Display the radius and calculated values // Sample output for radius 5 // The radius: 5.0 System.out.println("The radius: "+radius); // The circle circumfer System.out.println("The circle circumference: " +result); 42 43 44 45 46 47 31.41 48 esc F1 F2 F3 F4 E5 F6 @ # $ % &
// Step 10: Display the radius and calculated values
// Sample output for radius 5
// The radius: 5.0
System.out.println("The radius: "+radius);
// The circle circumference: 31.41592653589793
System.out.println("The circle circumference: " +result);
// The circle area: 78.53981633974483
System.out.println("The circle area: "+area);
// The sphere surface area: 314.1592653589793
System.out.println("The sphere surface area: "+ SurfaceArea);
// The sphere volume: 523.5987755982989
System.out.println("The sphere volume:
43
44
45
46
47
48
49
50
51
52
53
54
+ volume);
55
56
57
58
}
59
CodeCheck
Reset
Download
esting CircleAndSphere.java
Test 1
Inpult
Actual
Expected
Enter the radius: The radius: 5.0
The circle circumference: 31.41592653589793 The circle circumference: 31.41592653589793
The circle area: 78.53981633974483
The sphere surface area: 314.1592653589793
The sphere volume: 39269.90816987241
Enter the radius: The radius: 5.0
The circle area: 78.53981633974483
The sphere surface area: 314.15926535
The sphere volume: 523.5987755982989
9793
MacBook Alir
881
esc
80
000
F1
F2
F3
F4
F5
F6
Transcribed Image Text:// Step 10: Display the radius and calculated values // Sample output for radius 5 // The radius: 5.0 System.out.println("The radius: "+radius); // The circle circumference: 31.41592653589793 System.out.println("The circle circumference: " +result); // The circle area: 78.53981633974483 System.out.println("The circle area: "+area); // The sphere surface area: 314.1592653589793 System.out.println("The sphere surface area: "+ SurfaceArea); // The sphere volume: 523.5987755982989 System.out.println("The sphere volume: 43 44 45 46 47 48 49 50 51 52 53 54 + volume); 55 56 57 58 } 59 CodeCheck Reset Download esting CircleAndSphere.java Test 1 Inpult Actual Expected Enter the radius: The radius: 5.0 The circle circumference: 31.41592653589793 The circle circumference: 31.41592653589793 The circle area: 78.53981633974483 The sphere surface area: 314.1592653589793 The sphere volume: 39269.90816987241 Enter the radius: The radius: 5.0 The circle area: 78.53981633974483 The sphere surface area: 314.15926535 The sphere volume: 523.5987755982989 9793 MacBook Alir 881 esc 80 000 F1 F2 F3 F4 F5 F6
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
InputStream
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.
Similar questions
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