Advertisement
Threed90

02.Spaceship

Oct 28th, 2018
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement