Didart

Beer Kegs

Jun 4th, 2021 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 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.         String biggestKeg = "";
  8.         int numberKegs = Integer.parseInt(scanner.nextLine());
  9.         double maxVolume = Double.MIN_VALUE;
  10.  
  11.         for (int i = 1; i <= numberKegs; i++) {
  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.             //double volume = Math.PI * radius * radius * height;
  18.            
  19.             if (volume > maxVolume) {
  20.                 maxVolume = volume;
  21.                 biggestKeg = model;
  22.             }
  23.         }
  24.         System.out.println(biggestKeg);
  25.     }
  26. }
  27.  
Add Comment
Please, Sign In to add comment