Answered step by step
Verified Expert Solution
Question
1 Approved Answer
my feedback for this lab was to elminate variables used only once. can someone explain that to me and how it should look? import java.util.Scanner;
my feedback for this lab was to elminate variables used only once. can someone explain that to me and how it should look?
import java.util.Scanner;
public class Circles
public static void mainString args
Method for radius calculation.
double radius getRadius;
Method for circumference calculation.
calculateCircumferenceradius;
Method for area calculation.
calculateArearadius;
Method for rounded area calculation.
calculateRoundedArearadius;
This method gets the radius from the user and returns the
userinput radius.
public static double getRadius
Instantiates the scanner.
Scanner in new ScannerSystemin;
Prompts the user for a radius and stores as a return double.
System.out.printlnRadius:;
return innextDouble;
This method calculates and displays the circumference of the
circle. The parameter is the radius of the circle.
public static void calculateCircumferencedouble radius
Calculates and outputs the circumference of the circle.
double circumference Math.PI radius;
System.out.printlnCIRCUMFERENCE circumference;
This method calculates and displays the area of the circle.
The parameter is the radius of the circle.
public static void calculateAreadouble radius
Calculates and outputs the area of the circle.
double area Math.PI Math.powradius;
System.out.printlnAREA area;
This method calculates and displays the rounded area of the
circle. The parameter is the radius of the circle.
public static void calculateRoundedAreadouble radius
Calculates the rounded area of a circle.
double area Math.PI Math.powradius;
Creates a variable for the rounded area and casts it
to an integer.
int roundedArea int Math.roundarea;
Outputs the rounded area.
System.out.printlnROUNDED AREA roundedArea;
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