Advertisement
Dianov

Data Types and Variables - Exercise (08. Beer Kegs)

Aug 7th, 2021
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BeerKegs
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int numberOfBeerKegs = int.Parse(Console.ReadLine());
  10.             string biggestModel = String.Empty;
  11.             double radius = 0.0;
  12.             int hight = 0;
  13.             double biggestVolume = int.MinValue;
  14.  
  15.             for (int i = 0; i < numberOfBeerKegs; i++)
  16.             {
  17.                 string model = Console.ReadLine();
  18.                 radius = double.Parse(Console.ReadLine());
  19.                 hight = int.Parse(Console.ReadLine());
  20.                 double currentVolume = Math.PI * radius * radius * (double)hight;
  21.                 if (currentVolume > biggestVolume)
  22.                 {
  23.                     biggestVolume = currentVolume;
  24.                     biggestModel = model;
  25.                 }
  26.             }
  27.             Console.WriteLine(biggestModel);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement