Advertisement
SUni2020

02.Spaceship

Mar 27th, 2020
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Spaceship_02 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double width = Double.parseDouble(scanner.nextLine());
  8. double length = Double.parseDouble(scanner.nextLine());
  9. double height = Double.parseDouble(scanner.nextLine());
  10. double humanHeight = Double.parseDouble(scanner.nextLine());
  11.  
  12. double racketVolume = width * length * height;
  13. double roomVolume = (humanHeight + 0.40) * 2 * 2;
  14. double people = Math.floor(racketVolume / roomVolume);
  15.  
  16. if (people >= 3 && people <= 10){
  17. System.out.printf("The spacecraft holds %.0f astronauts.", people);
  18. } else if (people < 3){
  19. System.out.println("The spacecraft is too small.");
  20. } else {
  21. System.out.println("The spacecraft is too big.");
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement