Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util.*;
  2. public class Walec
  3. {
  4. public Walec() {
  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. System.out.println("Podaj wysokość: ");
  14. double b = in.nextDouble();
  15. if(a<=0 || b<=0) {
  16. System.out.println("Promień lub wysokość nie może być mniejszy lub równy 0");
  17. }
  18. if(a > 0 && b > 0) {
  19. double c = 3.14;
  20. double d = c * Math.pow(a , 2);
  21.  
  22. System.out.println("Objętość twojego walca wynosi: "+d*b);
  23. }
  24. } catch (InputMismatchException e) {
  25. System.out.println("Tylko liczby!");
  26. }
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement