Andreeva-Magdalena97

Spaceship

Mar 31st, 2019
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package Exem31March;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Spaceship {
  6.     public static void main(String[] args) {
  7.         Scanner s = new Scanner(System.in);
  8.  
  9.         double widht = Double.parseDouble(s.nextLine());
  10.         double lenght = Double.parseDouble(s.nextLine());
  11.         double hight = Double.parseDouble(s.nextLine());
  12.         double astro = Double.parseDouble(s.nextLine());
  13.  
  14.         double volume = widht*lenght*hight;
  15.         double personVol = (astro + 0.40)*2*2;
  16.         double allSpace = Math.floor(volume/personVol);
  17.  
  18.         if (allSpace >=3 && allSpace <=10){
  19.             System.out.printf("The spacecraft holds %.0f astronauts.", allSpace);
  20.         }else if (allSpace < 3){
  21.             System.out.println("The spacecraft is too small.");
  22.         }else {
  23.             System.out.println("The spacecraft is too big.");
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment