Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

Development of Simple Menu Driven Program

Question

Project Specification
For this assignment you are required to specify, design, implement and test a menu driven program of your own design. You are to imagine that you are developing a prototype for entering the initial records of a system and providing reports from that system. For example you could design a program that supports entering membership details of a club or entering records of student grades within a class or any system you can imagine involving storing personal details in a two dimensional array. You are provided with incomplete sample starter code that you can modify and build upon. You are expected to fully comment the provided code as well as your own code.
Code Comprehension Sample code has been provided in Moodle. Use the sample code provided to answer the following questions:
1. When the program is first run and menu item 3 is selected what is displayed? Explain what has happened?
2. When the program is run and menu item 1 is selected and then menu item 3 is selected what is displayed?
3. If the program is run, menu item 1 is selected and the user attempts to add in 4 members what will happen and why?
4. Explain how the loop displaying the menu and processing a response is exited. What value does userOptionSelected have when the program finishes? Describe what happens on this line: userOptionSelected = m.getsel(scan); // get a user option entered.
5. The reserved word break is used in the switch-statement to manage the menu selection. What happens if you remove the break statement in case 3?
6. Currently, if the user enters an incorrect menu selection (such as 5) what happens? Explain why the error message is displayed. What method and line of code is responsible and why.
7. What alternative looping structure could have been used for the main while loop?
8. Explain the purpose of the boolean variable finished.
9. Briefly explain the two lines of code that have been used to create the array to store the scores for each competitor. In your explanation, provide a diagram to illustrate how the array is stored.
10. Explain what would happen (and why) if the code in the while loop was changed to: while(finished==true)
11. Currently, menu item one prompts the user for data for up to 3 rows of data and 4 values in each row. What change would you have to make to the code so that the data contains 8 rows of data, with 8 values on each row?
12. The design of the output for menu selection 2 needs to be changed so that it displays the data as per the following:
Row 1: Smith,Bruce 22 1 12.00
=============================
Row 2: Brown,Peter 24 2 12.00
=============================
Row 3: Maison,Mark 38 3 6.00
=============================
Provide the changes to the code that you need to make to do this.

Answer:

Program Requirements

  1. Number of Cols
  2. Number of Rows
  3. Member data such as Name, Age, Level and Fee

Algorithm

Step 1: Program Starts

Step 2: variable declaration

Step 3: Infinite while loop starts

Step 4: Read the user choice


Step 5: Check if the user choice is 5, go to Step 11

Step 6: Check if the user choice is 1, system read the data of rows, cols and member data and stored into two dimensional array, then go to Step 10

Step 7: Check if the user choice is 2, system display the two dimensional array values, then go to Step 10

Step 8: Check if the user choice is 3, system calculates sum and average age of all member details and print the average age and then go to Step 10

Step 9: Check if the user choice is 4, system calculates sum of member fee and display it. Go to Step 10

Step 10: Go to Step 3

Step 11: Program Ends 

 (1) If we select the menu item 3, the following result will be displayed,

Number of row limit is 3, so the system validate input and display the error message and then read the another value for row (ie, number of members)

(4) The loop displaying the menu and processing a response is exited are as follows

What value does userOptionSelected have when the program finishes?

If userOptionSelected is 5, the program finished

Describe what happens on this line:

userOptionSelected = m.getsel(scan); // get a user option entered.

getsel is a function, it has one parameter which is a scanner object. It is used to read the user option. And the function returns the user choice value and stored into userOptionSelected variables
(5)
If we remove the break statement in case 3,

Assumption1:
userOptionSelected is 3, the control move to case 3, then execute the case 3 method then control move to case 4 and process the case 4 method also. So that we must use break in all case

If user enter the selection is 6, system displays the error message. Because default case of switch statement will be executed.


(7) We may use do..while loop statement instead of while loop

(8) The purpose of the boolean variable finished is.
In while statement, it checks the Boolean value or relational expression. So that we used Boolean value for handling while loop. If finished is true, control exit from the loop, otherwise, control process the loop

(9) The Explaination of two lines of code that have been used to create the array to store the scores for each competitor with a diagram to illustrate how the array is stored.
Integer[][] score;
Score=new Integer [5][6];
Row is 5, columns is 6.
Five competitor and 6 scores for each competitor 

 

0

1

2

3

4

5

Competitor0

10

5

12

20

12

15

Competitor1

      

Competitor2

      

Competitor3

      

Competitor4

      

Competitor5

      

(10) Iif the code in the while loop was changed to then:

while(finished==true)

Loop will be infinite


(11) Currently, menu item one prompts the user for data for up to 3 rows of data and 4 values in each row.

Then the changes will have to make to the code so that the data contains 8 rows of data, with 8 values on each row are as follows?

We can store the data for 8 x 8 matrixes. But we need to define the field such as address, city, and etc

We need to define and add the fields as same as the below (Name, Age, Level and Fees)


(12) The design of the output for menu selection 2 needs to be changed so that it displays the data as per

the following:

Row 1: Smith,Bruce 22 1 12.00

============================================

Row 2: Brown,Peter 24 2 12.00

============================================

Row 3: Maison,Mark 38 3 6.00

============================================

Provide the changes to the code that you need to make to do this.

We need to set the number of cols is 4 and number of row is 3


Buy Development of Simple Menu Driven Program Answers Online

Talk to our expert to get the help with Development of Simple Menu Driven Program Answers to complete your assessment on time and boost your grades now

The main aim/motive of the management assignment help services is to get connect with a greater number of students, and effectively help, and support them in getting completing their assignments the students also get find this a wonderful opportunity where they could effectively learn more about their topics, as the experts also have the best team members with them in which all the members effectively support each other to get complete their diploma assignments. They complete the assessments of the students in an appropriate manner and deliver them back to the students before the due date of the assignment so that the students could timely submit this, and can score higher marks. The experts of the assignment help services at urgenthomework.com are so much skilled, capable, talented, and experienced in their field of programming homework help writing assignments, so, for this, they can effectively write the best economics assignment help services.

Get Online Support for Development of Simple Menu Driven Program Assignment Help Online

Copyright © 2009-2023 UrgentHomework.com, All right reserved.