Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E02spaceship {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double width = Double.parseDouble(scanner.nextLine());
- double length = Double.parseDouble(scanner.nextLine());
- double height = Double.parseDouble(scanner.nextLine());
- double averageHeight = Double.parseDouble(scanner.nextLine());
- double roomWidth = 2;
- double roomLength = 2;
- double roomHeight = averageHeight + 0.40;
- double roomSize = roomWidth * roomLength * roomHeight;
- double spacecraft = width * length * height;
- double astronauts = spacecraft / roomSize;
- if (astronauts >= 3 && astronauts <= 10 ){
- System.out.printf("The spacecraft holds %.0f astronauts.", Math.floor(astronauts));
- }
- else if ( astronauts < 3 ){
- System.out.println("The spacecraft is too small.");
- }
- else if (astronauts > 10) {
- System.out.println("The spacecraft is too big.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment