Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package circle;
- import java.util.Scanner;
- /**
- *
- * @author window user
- */
- public class Circle {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- double pie = 3.14159;
- String input;
- char letter;
- Scanner key = new Scanner(System.in);
- System.out.println("Enter the radius of the circle: ");
- double radius = key.nextDouble();
- System.out.println("Enter C to calculate circumference or enter A to calculate area of the circle: ");
- input = key.nextLine();
- letter = input.charAt(0);
- switch (letter){
- case 'a':
- case 'A':
- double area = radius*radius*pie;
- System.out.println("Area of the circle is: " + area);
- case 'c':
- case 'C':
- double circumference = 2*radius*pie;
- System.out.println("Circumference of the circle is " + circumference);
- default:
- System.out.println("Enter c to calculate circumference or enter A to calculate are of the circle");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment