Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.*;
  2. public class Kolo
  3. {
  4. public Kolo() {
  5. boolean run = true;
  6. while(run) {
  7. Scanner in = new Scanner(System.in);
  8.  
  9. try {
  10. System.out.println("Podaj promień: ");
  11. double a = in.nextDouble();
  12.  
  13. if(a<=0) {
  14. System.out.println("Promień nie może być mniejszy lub równy 0");
  15. }
  16. if(a > 0) {
  17.  
  18. double c = 3.14;
  19. double d = c * Math.pow(a , 2);
  20. System.out.println("Pole twojego koła wynosi: " +d+ ".\n");
  21.  
  22. double e = 2*c*a;
  23. System.out.println("Obwód twojego koła wynosi: "+e+".\n");
  24. }
  25. } catch (InputMismatchException e) {
  26. System.out.println("Tylko liczby!");
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement