Advertisement
desislava_topuzakova

02. SpaceShip

May 13th, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Spaceship {
  4.     public static void main(String[] agrs) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double width = Double.parseDouble(scanner.nextLine());
  8.         double length = Double.parseDouble(scanner.nextLine());
  9.         double height = Double.parseDouble(scanner.nextLine());
  10.         double average = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double volumeRacket = width * length * height;
  13.         double volumeRoom = 2 * 2 * (average + 0.40);
  14.         int people = (int) (Math.floor(volumeRacket / volumeRoom));
  15.  
  16.         if (people >= 3 && people <= 10) {
  17.             System.out.printf("The spacecraft holds %d astronauts.", people);
  18.         } else if (people < 3) {
  19.             System.out.println("The spacecraft is too small.");
  20.         } else if (people > 10) {
  21.             System.out.println("The spacecraft is too big.");
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement