Assignment
Overview
This is an individual assignment that requires you to design, develop and test a small procedural Java program.
Learning Outcomes Assessed
The following course learning outcomes are assessed by completing this assessment:
- Identify and use the correct syntax of a common programming language
- Recall and use typical programming constructs to design and implement simple software solutions
- Reproduce and adapt commonly used basic algorithms
- Utilise pseudocode and/or algorithms as a major program design technique
- Write and implement a solution algorithm using basic programming constructs
- Demonstrate debugging and testing skills whilst writing code
- Develop self-reliance and judgement in adapting algorithms to diverse contexts
- Design and write program solutions to identified problems using accepted design constructs
Assessment Details
Housing affordability for first home owners has been discussed recently in the Australian media. It became a headline discussion when one commentator made the remark that young people could afford to save for a deposit if they stopped buying avocado on toast and takeaway coffees.
Your employer wants you to develop a small Java program that allows users to enter the cost to purchase properties in the user's area, then calculates how many purchases of avocado on toast would be required to save a 20% deposit to purchase those properties. For example, if a house in a particular area cost $400,000 to purchase, a 20% deposit amounts to $80,000. This equates to 4000 purchases of avocado on toast at $20 per serve.
Stage 1: Design
This stage requires you to prepare documentation that describes the function of the program and how it is to be tested. There is no coding or code testing involved in this stage. A document template has been provided for your use.
Requirements:
1) Read through Stage 2: Program Development to obtain details of the requirements of this program.
2) Write an algorithm, pseudocode or draw a flowchart that describes how the program will operate.
a. All program requirements - base, standard and advanced - must be included, even if you do not end up including all these requirements in your program code.
b. The algorithm, pseudocode or flowchart must be structured logically so that the program would function correctly.
This documentation is aimed at helping you think clearly about how your program must work, so you understand the logic of the program before you attempt to code it. Spending time on this documentation before you begin coding will make it much easier for you to develop your program.
3) Prepare and document test cases that can be used to check that the program works correctly, once it has been coded. You do NOT need to actually run the test cases in this stage; testing will occur in Stage 3: Testing.
a. All program requirements - base, standard and advanced, must be included, even if you do not end up including all these requirements in your program code.
b. Make sure the test cases include checking of data entered by the user to make sure that only valid data is accepted. If the user enters invalid data, the user should be informed of this and given another chance to enter the data. NB: As we have not covered exception handling, you may assume that the user will always enter integer values. This includes entering prices in whole amounts of dollars, ignoring the cents.
c. Test cases should be documented using a template like the one below. You may include extra information if you wish. At this stage, the Actual Result column will be left blank.
Stage 2: Program Development
Using your Design Documentation to assist you, develop a Java program that records house prices for an area then compares the deposit required to purchase these with the cost of purchasing avocado on toast, implementing the requirements outlined in this section. These requirements have been broken into three groups:
- Base Functionality includes the minimal level of requirements to achieve the essential components of this assignment. This group of requirements focuses on getting the code to work and on using the programming constructs we cover in class. You can expect to use constants, variables, loops, conditional statements and arithmetic operators for these requirements and you should look for opportunities to use these wherever you can. You will not receive full marks for implementing a requirement, even if it works, if you have not used the appropriate programming construct to do so.
At this level, you can decide if it is easier for you to code everything within a single method initially, or to modularize it straight away.
- Standard Functionality ensures the code is modularized, and that method calls are used to ensure the program flows correctly. It allows data to pass from one method to another as parameters.
- Advanced Functionality provides a challenge task, and is best left until all the other requirements have been addressed. It requires using the Java API to investigate and implement appropriate methods of the GregorianCalendar class.
You are expected to follow coding conventions, such as proper layout of code, using naming conventions and writing meaningful comments throughout your program.
An example of the program running is included in the Appendix for your reference.
Base Functionality:
1. Display a welcome message when the program starts
- The welcome message should have a row of asterisks at the top and the bottom, just long enough to extend over the text. Hint: Use a For loop for this.
- The first line of the message should read "SAVE A HOUSE DEPOSIT CALCULATOR" and be approximately centred in the row of asterisks by printing white space first. Hint: Can you modify the For loop from the previous step to print the white spaces?
- A second line of the message should be blank.
- The third line should read "Developed by" followed by your name and a comma, then " student ID ", then your student id, then finally " for ITECH1000 Sem 2 2017".
- The fourth line should be blank.
- The fifth line should repeat the initial line of asterisks.
2. Provide a menu from which the user can select Enter House Prices, Enter Avocado on Toast Price, Deposit Calculator or Exit System. This menu should be repeated each time after the user has chosen and completed an option until the user chooses to Exit System. The user selects an option by entering the number listed next to it. If an invalid number is selected, the user is advised and shown the menu again to make another selection.
3. When the user selects the Enter House Prices option, prompt the user to enter the house prices for the area. The user should be prompted three times, first for the cheapest house listing, second for the chosen house listing, and third for the median house listing. After each prompt, the system reads and saves a positive, whole number value from the user before proceeding. The system should also ensure that the value provided for the cheapest house is the cheapest of all three options entered. When all three values have been entered, the menu is redisplayed.
Note: the lighter values are user-entered while the program is running and may change each time.
4. When the user selects Enter Avocado on Toast Price, prompt the user to enter the price to purchase Avocado on Toast from a local café or restaurant. This should be a positive, whole number value only. Once the user has entered this value, save it for later access and redisplay the menu.
5. When the user selects Deposit Calculator, display a calculation of how many smashed avocados on toast the user will need to not buy in order to save the deposit for each of the three house prices specified. This uses the data provided in Steps 3 and 4.
a. The amount of the deposit is a flat 20% of the overall price of each property.
b. The number of avocados required may not be a whole number and should be displayed with 2 decimal places. You can obtain the number of avocados on toast required by dividing the amount of the deposit by the price of a single avocado on toast.
c. The deposit required should be displayed to 2 decimal places.
d. After displaying the calculations, the menu should be redisplayed.
6. When the user selects Exit System, quit the program with a message to the user.
Standard Functionality:
7. Modularize the code, correctly using method calls and passing data between methods as parameters.
8. Ensure the code complies with coding standards. This includes:
a. Commenting the code so that it is clear what the code is doing and anything potentially unclear to future developers is explained. Hint: A well-documented algorithm / pseudocode / flowchart is an excellent starting point for this.
b. Replace any "magic numbers" with constants or variables, as appropriate. All values that have consistent values throughout the program should be stored as constants.
c. Indent the code and include white space as required to improve its readability.
d. Ensure all variables and constants have clear names that reflect their purpose
Advanced Functionality:
9. Enhance the Deposit Calculator to provide a date by which the deposit would be saved for the chosen house, based on a user-specified number of avocado on toast purchases per week.
a. Use the GregorianCalendar class to manage your dates. You will need to import java.util.GregorianCalendar to use this library.
b. Prompt the user to enter the number of times per week they purchase avocado on toast. The user must enter a positive whole number - not 0 - before the program will proceed.
c. Display a message to the user to advise when the house deposit would be accumulated by saving the money it would take to purchase the avocado on toast.
i. Base the deposit on the value of the user's chosen house
ii. Use the date the user runs the program as the starting date
iii. Provide your calculation in whole weeks only. You do not need to determine the exact day a deposit would be saved, only the week it would be available.
d. Redisplay the menu after the calculation has been displayed.
NB: The methods and attributes of the GregorianCalendar class are not explicitly taught in class. This task requires you to apply what you have learnt about reading the Java API to find a way to implement the functionality.
Stage 3: Testing
Using a copy of the test cases developed in Stage 1: Design, test the program you have developed in
Stage 2: Program Development. Document your results, including both failed and successful tests.
Note: Please do not leave out any failed tests. If your testing highlights that your program has not worked correctly, then the failed tests help to demonstrate that you have been testing your program properly.
To show that you have tested your program, include small (but readable) screen captures in your Actual Results as well as any explanatory comments. Microsoft Windows includes a Snipping Tool that is useful for taking captures of the relevant parts of the screen.
You may test your program in phases if you wish. Stage 2: Program Development provides three separate groups of functionality in the requirements, working from the minimal level of requirements through to more advanced concepts. Each of these groups can be tested individually.
Base Functionality:
This phase requires you to check that the base functions (displaying welcome message when the program starts, showing a menu of options until the user chooses to exit, entering house price details for the three pricing levels, entering the cost of purchasing avocado on toast, displaying the deposit calculation and exiting the system) have been implemented.
Standard Functionality:
This section does not include any functionality beyond that of the base functionality, however if you needed to make changes to your code to implement modularization and coding standards, testing is required to ensure that the code still works properly once these changes have been made. Small changes made to code can quite often result in bugs so retesting is important to confirm the correct behaviour has been retained.
Advanced Functionality:
This phase requires testing the code that calculates and displays the week in which the deposit will be saved by not purchasing a user-specified number of avocado on toasts per week.
Attachment:- Assignment specification.rar