Advertisement
Kancho

Biggest_Keg

Feb 27th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Soft_Uni_Varibles {
  4. public static void main(String[] args) {
  5. Scanner key = new Scanner(System.in);
  6. System.out.print("Number: ");
  7. int n = Integer.parseInt(key.nextLine());
  8. // double volume = 0;
  9. String biggestKeg = "";
  10. double biggestVolume = 0.0;
  11. for (int i = 0; i < n; i++) {
  12. System.out.print("Model: ");
  13. String model = key.nextLine();
  14. System.out.print("radius: ");
  15. double r = Double.parseDouble(key.nextLine());
  16. System.out.print("height: ");
  17. double h = Double.parseDouble(key.nextLine());
  18. double volume = Math.PI * (Math.pow(r, 2)) * h;
  19. if (volume > biggestVolume) {
  20. biggestVolume = volume;
  21. biggestKeg = model;
  22. }
  23. }
  24. System.out.printf("The model of biggest keg is %s%n", biggestKeg);
  25. System.out.printf("It has volume %.2f ", biggestVolume);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement