Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BeerKegs {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String biggestKeg = "";
- int numberKegs = Integer.parseInt(scanner.nextLine());
- double maxVolume = Double.MIN_VALUE;
- for (int i = 1; i <= numberKegs; i++) {
- String model = scanner.nextLine();
- double radius = Double.parseDouble(scanner.nextLine());
- int height = Integer.parseInt(scanner.nextLine());
- double volume = Math.PI * Math.pow(radius, 2) * height;
- //double volume = Math.PI * radius * radius * height;
- if (volume > maxVolume) {
- maxVolume = volume;
- biggestKeg = model;
- }
- }
- System.out.println(biggestKeg);
- }
- }
Add Comment
Please, Sign In to add comment