Guest User

Untitled

a guest
Oct 13th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package circle;
  7. import java.util.Scanner;
  8. /**
  9. *
  10. * @author window user
  11. */
  12. public class Circle {
  13.  
  14. /**
  15. * @param args the command line arguments
  16. */
  17. public static void main(String[] args) {
  18. // TODO code application logic here
  19. double pie = 3.14159;
  20. String input;
  21. char letter;
  22. Scanner key = new Scanner(System.in);
  23. System.out.println("Enter the radius of the circle: ");
  24. double radius = key.nextDouble();
  25. System.out.println("Enter C to calculate circumference or enter A to calculate area of the circle: ");
  26. input = key.nextLine();
  27. letter = input.charAt(0);
  28. switch (letter){
  29. case 'a':
  30. case 'A':
  31. double area = radius*radius*pie;
  32. System.out.println("Area of the circle is: " + area);
  33. case 'c':
  34. case 'C':
  35. double circumference = 2*radius*pie;
  36. System.out.println("Circumference of the circle is " + circumference);
  37. default:
  38. System.out.println("Enter c to calculate circumference or enter A to calculate are of the circle");
  39. }
  40.  
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment