Question: Problem Description: Displaying menu options and performing operations base&sh usprecheiesu Colleges For this Lab your program must perform two different operations based on a user's







Problem Description: Displaying menu options and performing operations base&sh usprecheiesu Colleges For this Lab your program must perform two different operations based on a user's input. To do this, you must show the user a menu, ask the user for their choice, perform the appropriate computation, and then repeat until the user chooses to exit. The menu is as follows: Please choose from following menu: 1) Print all integer numbers between two given integers. 2) Display a right triangular pattern of stars. 3) Quit. Step 1: Getting Started Create a class called Lab5. Use the same setup for setting up your class and main method as you did in previous labs and assignments. Be sure to name your file Lab5.java. Assignment Documentation: At the beginning of each programming assignment you must have a comment block with the following information: -- - - - -- - - - - - - - - -- - - - - - - - - - - - - - - - - - - -- - - - // AUTHOR: your name // FILENAME: title of the source file // SPECIFICATION: description of the program // FOR: CSE 110- Lab #5 // TIME SPENT: how long it took you to complete the assignment //-------------- -- - - - - - - - Step 2: Beginning the loop and declaring variables ASU Home My ASU Colleges & The first part of the problem is to show the user the menu, collect the user's menu choice as an input, and repeat it until the user selects the exit option. For this, we need to declare a variable named choice to store the user choice. int choice = 0; Next, we must select the appropriate loop for the main body of the program. In this case, since we know that the program should execute at least once, a do-while loop is most appropriate. Inside the loop, print the menu using System.out.println statements and then request the menu option from the user. A skeleton do-while loop follows. Remember to add the Scanner statement that requests the choice from the user. do{ //Please choose from following menu: // 1) Print all integer numbers between two given integers. // 2) Display a right triangular pattern of stars. // 3) Quit. // Use scanner to collect user input } while(/*condition*/); Remember every loop must have a condition. Here the loop should run until user chooses option 3. So the condition would be (choice != 3) Step 3: Performing operations ASU Home My ASU Colleges Based on the choice entered by the user, we need to do some operations. Inside the do-while loop, but after the menu, initialize a switch-case statement to perform the operations. The switch-case statement hinges on the choice variable, which should now have an integer value. An example switch-case statement follows. switch(choice) { case 1:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
