Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA HELP : MODIFY THE CODE BELOW TO THE FOLLOWING REQUIREMENTS : 1. allow the user to select a menu option that calls a method

JAVA HELP : MODIFY THE CODE BELOW TO THE FOLLOWING REQUIREMENTS :

1. allow the user to select a menu option that calls a method that will run a counting program. This counting program will also use a menu.

2.That menu will allow the user to display a series of numbers based on user input. The user will have two choices of how to count.

3.The first choice will be to count from a starting number, by an interval, up to some maximum value. This will require the user to enter a starting number, an interval, and a stop by number.

4.The second choice will be to count from a starting number by an interval some number of times. This will require the user to enter a starting number, an interval, and a maximum count. Do not display a number that is either larger than the stopping number or is not in the series of interval numbers. Validate that the series of numbers is at least two numbers long. For example, do they want to count by 2s, 7s, ?? etc. Display the warning "The ending number needs to be at least one counting interval lager than the starting number!" and do not display any numbers if the ending number is not at least 1 interval larger than the starting number. Insert a loop that will allow the user to repeat the program as many times as they wish asking each time if the user would like to repeat the program. When they finish the counting program, return to the main menu. Use menus when giving the user a choice, and validate their choice before executing that choice. Exit all programs using a menu choice.

MODIFY THIS CODE :

public class MenuChoices

{

private static Scanner keyboard = new Scanner(System.in);

public static void main(String[] args)

{

String menuChoice = "";

do

{

System.out.println("A) choice 1");

System.out.println("B) choice 2");

System.out.println("Q) Quit");

System.out.println("Please select a menu item.");

do

{

System.out.println("Enter \"A\", \"B\", or \"Q\" ");

menuChoice = keyboard.nextLine().toLowerCase().trim();

} while (!menuChoice.equals("a") && !menuChoice.equals("b") && !menuChoice.equals("q"));

switch (menuChoice)

{

case "a":

moduleOne();

break;

case "b":

moduleTwo();

break;

default:

System.out.println("Good-bye!!!");

break;

}

System.out.println("An excilent choice!");

} while (!menuChoice.equals("q"));

}

private static void moduleTwo()

{

System.out.println("You are in module two!");

}

private static void moduleOne()

{

System.out.println("You are in module one!");

}

}

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

Step: 3

blur-text-image

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago