Development of a simple menu driven program

Assignment Help JAVA Programming
Reference no: EM13825185 , Length:

For this assignment you will be provided with incomplete sample starter code that you can modify and build upon. Your task will be to carry out the design, analysis, coding and testing to add several additional features to this sample code. You are expected to fully comment the provided code as well as your own code. The sample code provided has some minor issues that mean that although the code compiles it does not run as required.

Project Specification

The program that is to be developed should enable the entry of data from a short survey and to provide the user with some short reports on this data.

The data to be entered is from a survey and initially includes the following information:

• Gender - male, female, other or unspecified

• Preferred hand - left, right, both

• Super power - invisibility, super strength

• Life preference - famous, happy

The program should present the user with a menu that provides the following functionality:

1. Input data
2. View data
3. View report and graph
4. View basic statistics

Further details on functionality are provided in the task specifications provided below.

Part A - Code Comprehension

Your task is to first answer some questions testing your comprehension of the partial solution. Use the sample code provided in StarterCode.java to answer the following questions. Include the answers in your assignment submission.

1. The code provided does not contain any comments.

a. Briefly explain why comments are important in code.

b. Update the code provided to include comments - include a copy of the commented code starter code in your assignment submission.

2. Identify all of the lines of code within the program that are associated with obtaining user input. This can be done by either copying the lines into your answers or highlighting the lines within the code.

3. The variable finished should be used as the condition for the while loop.

a. Briefly explain the purpose of the variable finished.

b. What value will it have when the while loop is initially entered?

4. Run the program. When the menu is presented enter 2 as the selected item.

a. What is the output of the program to the console? Why are all the values 0?

b. Briefly explain how would you should alter the code below so that it displays an appropriate prompt, rather than "Enter Response 1" for each loop:

case 1: System.out.println("Menu selection 1");
for(int i=0;i<surveyResponses.length;i++){
System.out.println("Enter Response 1");

5. Identify the lines that would need to be altered so that the menu is controlled by a do-while loop rather than the while- loop and provide the new lines of code required

6. Currently a switch-statement is used within the program to handle the different menu options. What other program structure could have been used?

7. Run the program.

a. use the following table to test the code provided:

Menu Selection

Expected

Actual

Notes

1

Displays "Menu selection 1" and prompts the user for the responses for gender

Displays "Menu selection 1"

As expected

2

Displays "Menu selection 2" and contents of the array for each student

 

 

3

Displays "Menu selection 3"

 

 

4

Displays "Menu selection 4"

 

 

5

Exits the program

 

 

-1

Error

 

 

-6

Error

 

 

b. Briefly outline the changes would you would need to make to the program so that it handles the menu entries correctly and exits the program when the user enters menu selection 4. Note: You do not need to make the changes in the code for Part A.

8. With the program an array has been used to store the data. Currently the code has two lines declaring the array, one that has been commented out.

a. Briefly explain both of the lines of code used to declare arrays.

b. Briefly explain why the programmer would include the declaration that has been commented out.

Part B - Program Analysis, Implementation and Development

It is suggested that you design, implement and test each of detailed below in order - completing each section completely and correctly before proceeding to the next. For each stage, with the exception of stage 1, you should:

1. design a solution in the form of pseudo-code to carry out the required task - include this pseudo-code as part of your project documentation, clearly indicating which stage it belongs to;

2. perform a desk check of your logic - if you find any problems with your pseudo-code you should redesign and retest;

3. implement the stage - update the code so that it implements the algorithm you have designed - at the end of each stage listed below save a copy of the code that has been developed and name each file appropriately;

4. test the stage - ensure that before moving onto the next stage of development that the program works and that there are no logic or runtime errors

Your code should use appropriate programming standards and be well documented/commented. You are permitted to discuss the sample program with your peers in order to understand it. However, you must ensure that you complete this section individually. It is expected that no two students will have the same program.

Development Stages

1. Update the code so that it:

a. includes at least two new super powers and two new life preferences;

b. includes at least 5 new responses in the test data that has been hard coded into the array;

c. exits the program when the user enters 4 for exit;

d. handles case 2 appropriately (ie does not fall through to case 3); and

e. displays an error if the user enters an incorrect selection from the menu.

2. Update menu item 1 case so that:

a. the response number is displayed correctly when prompting the user to enter data - this should start at 1;

b. the program prompts the user for the survey results to be entered for each respondent and stores the data into the correct positions within the array. For example:

Gender (1=Male 2=Female 3=Other 4=Unspecified) :
Left or right handed (1=Left 2=Right 3=Both):
Super power (1=Invisibility 2=Super strength 3=...):
Life preference (1=Famous 2=Happy 3=....):
Age (in years):

3. Update menu item 2 so that it displays all of the raw data that is stored in the array. For example:

Num

Gender

Lefty?

Power

Life

Age

0

0

0

0

1

29

1

1

1

1

0

20

Etc..

 

 

 

 

 

4. Update menu item 3 -.display at least one graph using the data that has been entered. For example you might display a histogram of the genders or super powers. Within your documentation you should design and briefly explain why you have decided to design that particular graph.

5. Update menu item 4 so that it displays a short report on the results. In your documentation you should provide a design the report and a brief explanation of why your report has been designed that way. Your report must include at least the following:

a. The age of the oldest or youngest respondent(s)
b. The average age
c. The super power that was the most or least popular

6. Data validation - add code to validate any data entered by the user. For example: for menu item 1 the data for gender should be validated so that only the values between 1 and 4) will be stored by the program; if an invalid test score is entered the user should be re-prompted to enter a new value until a valid score is entered.

7. Final Challenge: Complete this only after you have completed all of the tasks have sufficient time. Copy of the code into a new file and break the program down so that it utilises methods to handle each of the menu items.

Part C - Testing

You should be testing your program as each stage is completed, and again once the program is complete. You should document the testing data, process and results (e.g. in the form of a table) and include this within your project documentation. Your mark for this section will reflect the thoroughness of your testing and the quality of your documentation.

Reference no: EM13825185

Questions Cloud

Explain the contract law that the court applied : Discuss the major issues addressed in the case you found. Explain the contract law that the court applied to the case and why. Then, determine at least one action in drafting the contract that either company to the dispute could have taken to avoi..
What is the marginal revenue : Monopoly a) Marginal Revenue A single seller of a video game console faces an aggregate demand of P (Q) = 500 -Q/2000 i. What is the total revenue function? ii. What is the marginal revenue?
Maintaining optimum inventory problem : Maintaining optimum inventory Problem
Define the production possibilities curve : Define the production possibilities curve in your own words.Could a nation's production possibilities curve ever shift inward? What are TWO factors that may cause this to occur?How can an economy achieve points that are outside the production possibi..
Development of a simple menu driven program : Identify all of the lines of code within the program that are associated with obtaining user input. This can be done by either copying the lines into your answers or highlighting the lines within the code.
Calculate price elasticity of demand for price of a product : The problem belongs to Economics and it is explore about using midpoint method for calculating the price elasticity of demand for the price of a product.
Explore the lemons problem : The questions explore the lemons problem with a third quality level, intermediate, whose repair costs are $500. Hence a buyer values this quality at $2,700 and a seller at $2,200.24.14 If each quality level is just as prevalent in the population, sho..
What amount should be reported in the balance sheet : Palmiero purchased a patent from Vania Co. for $1,500,000 on January 1, 2010. What amount should be reported in the balance sheet for the patent, net of accumulated amortization, at December 31, 2012
Maintaining optimal level of stock problem : Maintaining Optimal Level of Stock Problem

Reviews

Write a Review

JAVA Programming Questions & Answers

  Tracer for java

Implementation of a tracer of Java objects and the tracer can be invoked from any point of a Java program, accepting an object as argument.

  Reading in strings from a text file into an array

If I am reading in strings from a text file into an array, where do I place this file at so that CodeBlocks will find it?

  What is an example of a javascript framework in the

what is an example of a javascript framework? in the framework you have described what is an example of an application

  Describe different professional levels in this discipline

What is Anesthesiology and critical care medicine describe the specific discipline, what is their focus (i.e., emergency medicine, education and prevention, psychiatric treatment etc.) Describe the different professional levels in this discipline

  Be sure to show all declarations

Write a function call that invokes function a. Be sure to show all declarations. However a complete main is not required.

  Implement a program to reverse the digits

Write a method, reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed. For example, the value of reverseDigit(12345) is 54321.

  Create a road class

Create a Road class. The class should have functions for setting the width of the road in feet and the length of the road in miles. It should also have functions for obtaining the width of the road the length of the road.

  Program that inputs a word representing a binary number

Write a program that inputs a word representing a binary number (0s and 1s). First your program should verify that it is indeed a binary number, that is the number contains only 0s and 1s.

  Write a method called makerow

Write a method called makeRow that is passed two arguments: an int and a String. It returns a String containing n copies of s, concatenated in a row. For instance, if we call the method with makeRow(5, "*"), the method returns *****.

  Determine the number is prime

Determine if the number is prime. If N is prime, then print a message stating that it is prime - If the integer is not between 0 and 8000000, then the program keeps prompting the user to re-enter the number till the integer is within the proper ran..

  1 linked listsin this problem you will write a class that

1 linked listsin this problem you will write a class that implements an ordered list of strings. your class will able

  Hash-join algorithm

In this assignment, you will have a chance to implement the hash-join algorithm for a DBMS. You can use C, C++, or Java to write the program. However, your program should include su- cient comments to make it readable. You need to turn in

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd