Ask Java Expert


Home >> Java

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;iSystem.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.

Java, Programming

  • Category:- Java
  • Reference No.:- M91395063
  • Price:- $90

Priced at Now at $90, Verified Solution

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As