Advertisement
Guest User

Untitled

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