Advertisement
Ivan_Bochev

Math Superstar

Mar 30th, 2019 (edited)
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package kr_2;
  2.  
  3. import java.util.*;
  4.  
  5. public class MathSuperstar {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.         String[] input = sc.nextLine().split(",");
  10.         double r1 = Double.parseDouble(input[0]) / 10;
  11.         double h1 = Double.parseDouble(input[1]) / 10;
  12.         double r2 = Double.parseDouble(input[2]) / 10;
  13.         double h2 = Double.parseDouble(input[3]) / 10;
  14.  
  15.         double V1 = Math.PI * r1 * r1 * h1;
  16.         double V2 = Math.PI * r2 * r2 * h2;
  17.  
  18.         if (Math.abs(V1 - V2) < 0.01) {
  19.             System.out.printf("V1=V2=%.2f", V1);
  20.         } else if (V1 > V2) {
  21.             System.out.printf("V1=%.2f", V1);
  22.         } else {
  23.             System.out.printf("V2=%.2f", V2);
  24.         }
  25.  
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement