Java
posted 1407 days ago
Patdziks
//import the scanner class
import java.util.Scanner;
public class main {
public static void main(String[] args) {
//TODO Auto-generated method stub
//Declare variables
String name;
double radius = 0,Circumference,Area;
//Display The Application Out
System.out.println("**********************");
System.out.println(" AREA OF A CIRCLE ");
System.out.println("**********************");
//Get input from users
Scanner inputDevice = new Scanner(System.in);
//Inform the user to enter the radius of the circle
System.out.println("Enter the radius:");
//Get the radius of the circle
name = inputDevice.nextLine();
//Consumes the enter key
inputDevice.nextLine();
//Now do the calculations
Circumference = 2*22/7*radius;
Area = 22/7 *2*radius;
//Display the results
System.out.println("***************************************");
System.out.println(" AREA AND CIRCUMFERENCE CALCULATIONS ");
System.out.println("***************************************");
System.out.println("Radius :7 ");
System.out.println("Area : "+22/7 *2*radius);
System.out.println("Circumference : "+2*22/7*radius);
}
}
0
Like
Patdziks
Alright sir will do that and see the outcome
1404 days
0
Like
Godwin Ashong
From your above code, you are not receiving the radius input from the user.
You are rather receiving name from your sample code:
Modify your code to take the radius instead. The radius is double data type so you should know the method to call on the Scanner object (inputDevice).
1405 days