Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SoftUni {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter the number of kegs you want to enter(1-10): ");
- String biggestKeg = "";
- double currentKegVolume = 0.0;
- int n = Integer.parseInt(sc.nextLine());
- for(int i = 0;i < n;i++){
- System.out.print("Model of keg number " + (i+1) + " is: " );
- String model = sc.nextLine();
- System.out.print("The radius of keg number " + (i+1) + " is: ");
- double radius = Double.parseDouble(sc.nextLine());
- System.out.print("The height of keg number " + (i+1) + " is: ");
- double height = Double.parseDouble(sc.nextLine());
- double volume = radius*radius*height*Math.PI;
- if(volume > currentKegVolume){
- currentKegVolume = volume;
- biggestKeg = model;
- }
- }
- System.out.println("The biggest keg is: " + biggestKeg);
- }
- }
Add Comment
Please, Sign In to add comment