Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to make a loop within a Driver class for a display menu. The loop is supposed to do the following: Main Method:

I am trying to make a loop within a Driver class for a display menu. The loop is supposed to do the following:

Main Method: Complete the code for the main() method. When your code is complete, test the output. Be sure that the completed method does the following:

a. Includes a loop that allows the user to interact with the menu until they signal that they want to exit the system.

b. Maps user input to the specified functionality based on the all menu options listed below.

The problem I am currently having is that my program does not loop, it exits after any single action is completed. This is what I have:

public static void main(String[] args) {

initializeShipList();// initial ships

initializeCruiseList();// initial cruises

initializePassengerList();// initial passengers

Scanner userInput = new Scanner(System.in);

char choice;

// add loop and code here that accepts and validates user input

// and takes the appropriate action. include appropriate

// user feedback and redisplay the menu as needed

do {

displayMenu();

choice = userInput.next().charAt(0);

switch(choice)

{

case '1':

addShip();

break;

case '2':

editShip();

break;

case '3':

addCruise();

break;

case '4':

editCruise();

break;

case '5':

addPassenger();

break;

case '6':

editPassenger();

break;

case 'A':

printShipList("name");

break;

case 'B':

printShipList("active");

break;

case 'C':

printShipList("full");

break;

case 'D':

printCruiseList("list");

break;

case 'E':

printCruiseList("details");

break;

case 'F':

printPassengerList();

break;

case 'x':

break;

case 'X':

break;

}

} while (!(choice != 'x' || choice!= 'X'));

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions