desislava_topuzakova

08. Beer Kegs

Jan 23rd, 2021
628
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class BeerKegs_08 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //вход: за всеки кег: model, radius, height
  7.         //обем = пи * радиус * радиус * височина
  8.         int countKegs = Integer.parseInt(scanner.nextLine());
  9.         double maxVolume = Double.MIN_VALUE;
  10.         String maxKegModel = "";
  11.         for (int keg = 1; keg <= countKegs; 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.                 maxKegModel = model;
  21.             }
  22.  
  23.         }
  24.  
  25.         System.out.println(maxKegModel);
  26.     }
  27. }
RAW Paste Data