Guest User

Untitled

a guest
Jun 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class K_R_Lifeboats
  3. {
  4.  
  5. public static void main(String[] args)
  6. {
  7. //Create a Scanner object
  8. Scanner input = new Scanner(System.in);
  9.  
  10. // Inform user what program they are using
  11. System.out.println("Lifeboat Capacity Analysis");
  12. System.out.println("--------------------------");
  13. // Inform user that they are about to enter some information
  14. System.out.println("\nFirst some information is needed...");
  15.  
  16. //ask user to enter the name of the ship
  17. System.out.print("\nEnter the name of the ship: ");
  18.  
  19. //create variable
  20. String shipName = input.nextLine();
  21.  
  22.  
  23. //ask the user to enter the number of people on board
  24. System.out.print("Enter the number of people on board the " +shipName+ ": " );
  25.  
  26.  
  27. //create variable
  28. double onBoard = input.nextDouble();
  29.  
  30. //ask the user to enter the maximum number of people per lifeboat
  31. System.out.print("Enter the maximum number of people per lifeboat: ");
  32.  
  33. //create variable
  34. double perBoat = input.nextDouble();
  35.  
  36. //ask the user the number of lifeboats that are available
  37. System.out.print("Enter the number of lifeboats that are avaliable on the " +shipName+ ": ");
  38.  
  39. //create variable
  40. double lifeBoats = input.nextDouble();
  41.  
  42. System.out.println("\nHere are the results...");
  43.  
  44.  
  45. System.out.println("A minimum of " + (onBoard % perBoat) + " lifeboats are required to rescue everyone on board");
Add Comment
Please, Sign In to add comment