DESCRIPTION Complete the program to calculate and print the circumference and area of a circle, rounded to the nearest tenth (1 decimal place). The starter
DESCRIPTION Complete the program to calculate and print the circumference and area of a circle, rounded to the nearest tenth (1 decimal place). The starter code already prompts the user and takes in the radius as a double-value input. You need to do the calculations and print the results. I recommend using the printf() command (described in chapter 3 of the book) to print the results with the correct rounding.
Sample output:
Enter the radius of a circle in centimeters: 5
Circumference = 31.4 cm
Area = 78.5 cm^2
Started code
//Must use printf()
import java.util.Scanner;
class Circle {
static Scanner sc = new Scanner(System.in); public static void main(String args[]) { System.out.print("Enter radius of circle in centimeters:"); double radius = sc.nextDouble();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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