Recent Question/Assignment

ITECH1000 Programming 1 1717
Assignment 1
This is an individual assignment that requires you to design, develop and test a small procedural Java program.
Timelines and Expectations
Percentage Value of Task: 20%
Due: 16:00 Friday 1st September (week 7) Minimum time expectation: 10 hours
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
1717 Assignment 1 specification.docx
ITECH1000 Programming 1 1717
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.
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.
1717 Assignment 1 specification.docx
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.
Test Case Expected Result Actual Result
The user selects the menu option: “Enter Avocado on Toast Price” The user is prompted to enter the purchase price in whole dollars of avocado on toast in their area.
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. Hint: you may find this site useful for validating the week specified:
Your program code and all documentation should be zipped into a single file and loaded into the Assignment Box provided in Moodle by the due date and time.
IMPORTANT NOTE: Make sure that you submit the source code (.java files) NOT the compiled program (.class files). Your work will NOT be marked if the .java files are not provided.
Marking Criteria/Rubric
Task Available Marks Student Mark
Stage 1: Design Documentation
Development of an algorithm, pseudocode or flowchart describing how the program should function
• All requirements from the Assessment Details section included 10
• Logical structure 10
Documented test cases to validate program
• All requirements from the Assessment Details section included
• Data is validated to ensure user entries are appropriate and incorrect user entries are handled smoothly
Stage 2: Program Development
A Java program addressing the requirements outlined in the Assignment Details section, including appropriate use of loops, conditional statements, constants and variables:
Base Functionality:
• Display of a welcome message when the program starts 2
• Menu displayed until user chooses to exit 5
• Enter House Prices to enter and record sample house prices 6
• Enter Avocado Toast Price to enter and record price of avocado on toast purchase 3
• Deposit Calculator to calculate and display the number of avocado on toast purchases required to save for a deposit worth 20% of house values 5
• Exit System to end the program with a message to the user. NB: program must finish by reaching end of program, not using System.exit() or similar. 1
Standard Functionality:
• Use of coding conventions throughout entire program, including readable and clear layout, following naming conventions and including meaningful and appropriate comments. “Magic Numbers” avoided. 8
• Code modularized, correctly using method calls and passing data between methods 10
Advanced Functionality:
• Price comparison data converted to years / months / days to save for deposit, based on user-entered frequency of purchasing avocado toast. 10
Stage 3: Testing
Documented test results clearly showing all the testing that has been conducted and the results of this testing. Failed tests do NOT result in a loss of marks.
• Test cases for all base functionality attempted and results documented 5
• Test cases for all standard functionality attempted and results documented 5
• Test cases for all advanced functionality attempted and results documented 5
Total 100
Assignments will be marked within 2 weeks of submission. Marks will be loaded in fdlGrades, and a completed marking sheet will be available via Moodle.
Plagiarism is the presentation of the expressed thought or work of another person as though it is one's own without properly acknowledging that person. You must not allow other students to copy your work and must take care to safeguard against this happening. More information about the plagiarism policy and procedure for the university can be found at
Example of Program Output:
********************************************************************** SAVE A HOUSE DEPOSIT CALCULATOR
Developed by Amy Meade, Student ID 30000000 for ITECH1000 Sem 2 2017
Please select an option from the menu:
1. Enter House Prices
2. Enter Avocado on Toast Price
3. Deposit Calculator
4. Exit System
You need to enter all house and avocado prices first
Please select an option from the menu:
1. Enter House Prices
2. Enter Avocado on Toast Price
3. Deposit Calculator
4. Exit System
House Details:
Enter asking price for cheapest house listing: $ a
Invalid input: please retry:
Enter asking price for your chosen house: $
Enter the median house value for this area: $
Please select an option from the menu:
1. Enter House Prices
2. Enter Avocado on Toast Price
3. Deposit Calculator
4. Exit System
Enter the price (in whole dollars) of avocado on toast from a local cafe or restaurant: $ 17
Please select an option from the menu:
1. Enter House Prices
2. Enter Avocado on Toast Price
3. Deposit Calculator
4. Exit System
You will need to NOT buy:
1764.71 smashed avocados on toast to save a $30000.00 deposit for the cheapest house
3235.29 smashed avocados on toast to save a $55000.00 deposit for your chosen house
4705.29 smashed avocados on toast to save a $79990.00 deposit for a house at the median price
************************************************************************************************* ***
How many times a week do you purchase avocado on toast?
Value must be greater than 0
If you stop buying avocado on toast starting from today and save the money instead, your deposit for a $275000 house will be saved in the week of 21/7/2079
************************************************************************************************* ***
Please select an option from the menu:
1. Enter House Prices
2. Enter Avocado on Toast Price
3. Deposit Calculator
4. Exit System 4
The House Deposit Calculator is now exiting.