Advertisement
StefanTobler

Activity 5 Lesson 3

Sep 11th, 2016
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. /*
  2.  * Lesson 5 Coding Activity Question 3
  3.  *
  4.  * Input the radius of a circle and print the circumference and area.
  5.  * The answer should be a decimal value.
  6.  *
  7.  * Remember the formula for circumference is 2 * pi * r and the formula
  8.  * for area is pi * r * r. You can use 3.14 for the value of pi in this activity.
  9.  *
  10.  * Sample Run:
  11.  
  12. Enter a radius:
  13. 4
  14. Circumference: 25.12
  15. Area: 50.24
  16.  
  17. */
  18.  
  19. import java.util.Scanner;
  20. import java.lang.Math;
  21.  
  22. class Lesson_5_Activity_Three {
  23.     public static void main(String[] args) {
  24.       Scanner scan = new Scanner (System.in);
  25.       System.out.println("Enter a radius: ");
  26.       int x = scan.nextInt();
  27.       System.out.println("Circumference: " + (6.28 * x));
  28.       System.out.println("Area: " + (3.14*(Math.pow(x,2))));
  29.      
  30.        }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement