Advertisement
deyanivanov966

EXAM 25.10 // 02. Spaceship

Oct 25th, 2020 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Izpit2 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double widht = Double.parseDouble(scanner.nextLine());
  7.         double lenght = Double.parseDouble(scanner.nextLine());
  8.         double height = Double.parseDouble(scanner.nextLine());
  9.         double avergHeigth = Double.parseDouble(scanner.nextLine());
  10.  
  11.         double totlaVolume = widht*lenght*height;
  12.         double roomVolume =  (avergHeigth+0.4)*2 *2;
  13.         double numberAustr = Math.floor(totlaVolume/roomVolume);
  14.         if (numberAustr<3){
  15.             double down = Math.floor(numberAustr);
  16.             System.out.println("The spacecraft is too small.");
  17.         }else if (numberAustr>10){
  18.             double down = Math.floor(numberAustr);
  19.             System.out.println("The spacecraft is too big.");
  20.         } else {
  21.             double down = Math.floor(numberAustr);
  22.             System.out.printf("The spacecraft holds %.0f astronauts.",numberAustr);
  23.         }
  24.  
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement