galinyotsev123

ProgBasicsExam16December2018-E02spaceship

Dec 30th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E02spaceship {
  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 averageHeight = Double.parseDouble(scanner.nextLine());
  11.  
  12. double roomWidth = 2;
  13. double roomLength = 2;
  14. double roomHeight = averageHeight + 0.40;
  15. double roomSize = roomWidth * roomLength * roomHeight;
  16.  
  17. double spacecraft = width * length * height;
  18. double astronauts = spacecraft / roomSize;
  19.  
  20. if (astronauts >= 3 && astronauts <= 10 ){
  21. System.out.printf("The spacecraft holds %.0f astronauts.", Math.floor(astronauts));
  22. }
  23.  
  24. else if ( astronauts < 3 ){
  25. System.out.println("The spacecraft is too small.");
  26. }
  27. else if (astronauts > 10) {
  28. System.out.println("The spacecraft is too big.");
  29. }
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment