Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create First_java_code.java #890

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Programming_Languages/Java/First_java_code.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Write a Java program to read the radius of a circle as an integer from the user. Calculate the diameter, circumference and area of the circle using the floating-point value of π = 3.14159. You can also use the value of π from the Math class which is available in java.lang.
Diameter = 2r
Circumference = 2 πr
Area = πr2
Solution by: Sanober494
*/

import java.lang.Math;
import java.util.Scanner;

public class First_java_code {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the radius of the circle:");
double radius = scanner.nextDouble();
System.out.println("Diameter of the circle is: " + 2 * radius);
System.out.println("Circumference of the circle is: " + 2 * Math.PI * radius);
System.out.println("Area of the circle is: " + Math.PI * Math.pow(radius, 2));
scanner.close();

}
}