nikolayneykov

Untitled

Oct 29th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. class Spaceship
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         double rocketWidth = double.Parse(Console.ReadLine());
  8.         double rocketLength = double.Parse(Console.ReadLine());
  9.         double rocketHeight = double.Parse(Console.ReadLine());
  10.         double astronautHeight = double.Parse(Console.ReadLine());
  11.  
  12.         double spaceshipVolume = rocketWidth * rocketLength * rocketHeight;
  13.         double roomVolume = (astronautHeight + 0.40) * 4;
  14.  
  15.         int totalAustronauts = (int)Math.Floor(spaceshipVolume / roomVolume);
  16.         string result = (totalAustronauts >= 3 && totalAustronauts <= 10) ?
  17.                         $"The spacecraft holds {totalAustronauts} astronauts." :
  18.                         totalAustronauts < 3 ? "The spacecraft is too small." :
  19.                         "The spacecraft is too big.";
  20.         Console.WriteLine(result);
  21.     }
  22. }
Add Comment
Please, Sign In to add comment