Advertisement
Sim0o0na

Untitled

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