Advertisement
Spocoman

Spaceship

Sep 9th, 2024
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double width = Double.parseDouble(scanner.nextLine()),
  7.                 length = Double.parseDouble(scanner.nextLine()),
  8.                 height = Double.parseDouble(scanner.nextLine()),
  9.                 averageHeight = Double.parseDouble(scanner.nextLine()),
  10.                 spaceshipVolume = width * length * height,
  11.                 astronautVolume = (averageHeight + 0.4) * 2 * 2;
  12.         int team = (int) (spaceshipVolume / astronautVolume);
  13.  
  14.         if (team < 3) {
  15.             System.out.println("The spacecraft is too small.");
  16.         } else if (team > 10) {
  17.             System.out.println("The spacecraft is too big.");
  18.         } else {
  19.             System.out.println("The spacecraft holds " + team + " astronauts.");
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement