Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Walec
- {
- public Walec() {
- boolean run = true;
- while(run) {
- Scanner in = new Scanner(System.in);
- try {
- System.out.println("Podaj promień: ");
- double a = in.nextDouble();
- System.out.println("Podaj wysokość: ");
- double b = in.nextDouble();
- if(a<=0 || b<=0) {
- System.out.println("Promień lub wysokość nie może być mniejszy lub równy 0");
- }
- if(a > 0 && b > 0) {
- double c = 3.14;
- double d = c * Math.pow(a , 2);
- System.out.println("Objętość twojego walca wynosi: "+d*b);
- }
- } catch (InputMismatchException e) {
- System.out.println("Tylko liczby!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement