Question
Can someone please help with the pseudocode for this program? import java.util.*; public class Circle_stats { //1.The main method that outputs an introduction to the
Can someone please help with the pseudocode for this program?
import java.util.*; public class Circle_stats { //1.The main method that outputs an introduction to the program. public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Welcome to the Round Object Calculator"); System.out.println("This program will calculate the area of a circle or the volume of a sphere."); System.out.println("The calculations will be based on the user input radius."); char response = 'Y'; char C_or_S; while(response == 'y' || response == 'Y') { System.out.print("Enter C for circle or S for sphere(Entry is Case Sensitive, Please Use Capital Letters):"); C_or_S = in.next().charAt(0); if(C_or_S == 'C') { System.out.print("Thank you. What is the radius of the circle (in inches):"); double radius = read_data(); display_output(radius, C_or_S, calc_area_circle(radius)); //7.As always, a program header, proper indentation and spacing, and adequate code comments are expect //Your program will end when the user enters a 0 for the radius of the circle. if(radius == 0.0) break; } else if(C_or_S == 'S') { System.out.print("Thank you. What is the radius of the sphere (in inches):"); double radius = read_data(); display_output(radius, C_or_S, calc_Volume_sphere(radius)); //7.As always, a program header, proper indentation and spacing, and adequate code comments are expect //Your program will end when the user enters a 0 for the radius of the circle. if(radius == 0.0) break; } else System.out.print("Invalid Choice: "); System.out.print("Do you want to calculate another round object (Y/N)? "); response = in.next().charAt(0); } goodbye(); } //2.A method that prompts for and accepts input from the user. public static double read_data() { Scanner in = new Scanner(System.in); return in.nextDouble(); } //3.A method that calculates the area of the circle using the input from step 2. public static double calc_area_circle(double radius) { return Math.PI*radius*radius; } //4.A method that calculates the area of a sphere using input from step 2. public static double calc_Volume_sphere(double radius) { return 4*Math.PI*radius*radius*radius/3; } //5.A method that outputs the result of both calculations. a.No output will exceed three decimal places. public static void display_output(double radius,char C_or_S, double result) { if(C_or_S == 'C') System.out.printf("The area of a circle with a radius of %.2f inches is: %.3f inches. ",radius, result); else System.out.printf("The volume of a sphere with a radius of %.2f inches is: %.3f cubic inches. ",radius, result); } //6.A method that thanks and says goodbye to the user just before the program terminates. public static void goodbye() { System.out.println("Thank you for using the Round Object Calculator. Goodbye. "); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started