Advertisement
Ligh7_of_H3av3n

02.Spaceship

Oct 21st, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. package SamiqtIzpit2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Spaceship {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double width = Double.parseDouble(scanner.nextLine());
  10.         double length = Double.parseDouble(scanner.nextLine());
  11.         double height = Double.parseDouble(scanner.nextLine());
  12.         double middleHeight = Double.parseDouble(scanner.nextLine());
  13.  
  14.         double x = Math.floor(width * length * height / ((middleHeight + 0.4) * 4));
  15.  
  16.         if (x >= 3 && x <= 10)
  17.         {
  18.             System.out.printf("The spacecraft holds %.0f astronauts.", x);
  19.         }
  20.         if (x < 3)
  21.         {
  22.             System.out.println("The spacecraft is too small.");
  23.         }
  24.         if (x > 10)
  25.         {
  26.             System.out.println("The spacecraft is too big.");
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement