8) Create the following program using Java. Circle calculation using methods Create scanner declare double variable radius =...

50.1K

Verified Solution

Question

Programming

8) Create the following program using Java.

Circle calculation using methods

Create scanner
declare double variable radius = -999
declare character choice

create do while loop
inside of do loop write:
System.out.println();
System.out.println(\"*** CIRCLE CALCULATIONS ***\");
System.out.println();
System.out.println(\"1. Enter the radius of the circle\");
System.out.println(\"2. Display the area of the circle\");
System.out.println(\"3. Display the circumference of thecircle\");
System.out.println(\"4. Quit\");
System.out.println();
System.out.println(\"Enter a number from 1 - 4\");
System.out.println();


Declare choice character and relate to scanner

declare switch (choice)

case 1 radius which is equal to option1 method

case 2 call option2(radius)

case 3 call option3(radius)

case 4 quit

default
prompt the user to enter numbers from 1 - 4
close bracket
while condition choice !='4'

create method static double option1 gets the user to enter theradius of the circle
declare myradius variable double
declare a scanner
prompt the user to enter the radius of circle and relate tovariable above with scaner
return the variable

create method static void option2 with parameter doubleradiusin
check condition id radiusin is equal to -999 display the message inconsole no radius is entered

else

declare variable double area
area is equal to 3.14 * radiusin * radiusin
display in console the area


create method static void option3 with parameter doubleradiusin
check condition id radiusin is equal to -999 display the message inconsole no radius is entered

else

declare variable double circumference
circumference is equal to 2 * 3.14 * radiusin
display in console the circumference

Answer & Explanation Solved by verified expert
3.9 Ratings (399 Votes)
package learningimport javautilpublic class Main static double option1 double myradius Scanner input new ScannerSystemin SystemoutprintEnter the radius of the circle myradius inputnextDouble return myradius static void    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students