Didart

Beer Kegs

Sep 24th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BeerKegs {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         double maxVolume = Double.MIN_VALUE;
  10.         String maxModelKeg = "";
  11.         for (int keg = 1; keg <= n; keg++) {
  12.             String model = scanner.nextLine();
  13.             double radius = Double.parseDouble(scanner.nextLine());
  14.             int height = Integer.parseInt(scanner.nextLine());
  15.            
  16.             double volume = Math.PI * Math.pow(radius, 2) * height;
  17.            
  18.             if (volume > maxVolume) {
  19.                 maxVolume = volume;
  20.                 maxModelKeg = model;
  21.             }
  22.         }
  23.         System.out.println(maxModelKeg);
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment