Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Soft_Uni_Varibles {
- public static void main(String[] args) {
- Scanner key = new Scanner(System.in);
- System.out.print("Number: ");
- int n = Integer.parseInt(key.nextLine());
- // double volume = 0;
- String biggestKeg = "";
- double biggestVolume = 0.0;
- for (int i = 0; i < n; i++) {
- System.out.print("Model: ");
- String model = key.nextLine();
- System.out.print("radius: ");
- double r = Double.parseDouble(key.nextLine());
- System.out.print("height: ");
- double h = Double.parseDouble(key.nextLine());
- double volume = Math.PI * (Math.pow(r, 2)) * h;
- if (volume > biggestVolume) {
- biggestVolume = volume;
- biggestKeg = model;
- }
- }
- System.out.printf("The model of biggest keg is %s%n", biggestKeg);
- System.out.printf("It has volume %.2f ", biggestVolume);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement