valiamaximova1

java

Mar 31st, 2021 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class java {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         System.out.print("Въведете радиуса: ");
  7.         double r = Integer.parseInt(scanner.nextLine());
  8.         System.out.print("Въведете височината: ");
  9.         double h = Integer.parseInt(scanner.nextLine());
  10.  
  11.         if (r <= 0 || h <= 0) {
  12.             throw new Error("Числата не може да са отрицателни!");
  13.         }
  14.         double S = Math.PI*r*r;
  15.         double V= Math.PI*r*r*h;
  16.         System.out.println("S = " + S);
  17.         System.out.println("Volume = " + V);
  18.  
  19.     }
  20.    
  21. }
  22.  
Add Comment
Please, Sign In to add comment