Threed90

02.Spaceship

Oct 28th, 2018
622
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace _02.Spaceship
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double width = double.Parse(Console.ReadLine());
  10.             double length = double.Parse(Console.ReadLine());
  11.             double height = double.Parse(Console.ReadLine());
  12.             double averageHeight = double.Parse(Console.ReadLine());
  13.  
  14.             double spaceShipVolume = width * length * height;
  15.             double roomVolume = (averageHeight + 0.40) * 2 * 2;
  16.  
  17.             int spaceShipPlaces = (int)Math.Floor(spaceShipVolume / roomVolume);
  18.  
  19.             if(spaceShipPlaces>=3 && spaceShipPlaces<=10)
  20.             {
  21.                 Console.WriteLine($"The spacecraft holds {spaceShipPlaces} astronauts.");
  22.             }
  23.             else if(spaceShipPlaces<3)
  24.             {
  25.                 Console.WriteLine("The spacecraft is too small.");
  26.             }
  27.             else if(spaceShipPlaces>10)
  28.             {
  29.                 Console.WriteLine("The spacecraft is too big.");
  30.             }
  31.         }
  32.     }
  33. }
RAW Paste Data