Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class K_R_Lifeboats
- {
- public static void main(String[] args)
- {
- //Create a Scanner object
- Scanner input = new Scanner(System.in);
- // Inform user what program they are using
- System.out.println("Lifeboat Capacity Analysis");
- System.out.println("--------------------------");
- // Inform user that they are about to enter some information
- System.out.println("\nFirst some information is needed...");
- //ask user to enter the name of the ship
- System.out.print("\nEnter the name of the ship: ");
- //create variable
- String shipName = input.nextLine();
- //ask the user to enter the number of people on board
- System.out.print("Enter the number of people on board the " +shipName+ ": " );
- //create variable
- double onBoard = input.nextDouble();
- //ask the user to enter the maximum number of people per lifeboat
- System.out.print("Enter the maximum number of people per lifeboat: ");
- //create variable
- double perBoat = input.nextDouble();
- //ask the user the number of lifeboats that are available
- System.out.print("Enter the number of lifeboats that are avaliable on the " +shipName+ ": ");
- //create variable
- double lifeBoats = input.nextDouble();
- System.out.println("\nHere are the results...");
- System.out.println("A minimum of " + (onBoard % perBoat) + " lifeboats are required to rescue everyone on board");
Add Comment
Please, Sign In to add comment