Advertisement
MladenKarachanov

Spaceship

Dec 18th, 2022
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. package programmingBasics;
  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. double width = Double.parseDouble(scanner.nextLine());
  9. double length = Double.parseDouble(scanner.nextLine());
  10. double height = Double.parseDouble(scanner.nextLine());
  11. double heightAstronauts = Double.parseDouble(scanner.nextLine());
  12. double sum = width * length * height;
  13. double volumeRoom = (heightAstronauts + 0.40) * 2 * 2;
  14. double placeFor = Math.floor(sum / volumeRoom);
  15.  
  16. if (placeFor >= 3 && placeFor <= 10) {
  17. System.out.printf("The spacecraft holds %.0f astronauts.", placeFor);
  18. } else if (placeFor < 3) {
  19. System.out.printf("The spacecraft is too small.",placeFor);
  20. } else if(placeFor>10){
  21. System.out.printf("The spacecraft is too big.",placeFor);
  22.  
  23.  
  24. }
  25. }
  26.  
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement