Foundation Programming Assignment: Australian Population Calculator
Goals and Topics
The assignment problem is straightforward. All necessary details have been supplied. The solution of the problem will use the programming concepts and strategies covered in Workshops 1-6. The subgoals are:
• Obtaining advanced understanding of values, variables and arrays;
• Understanding program input and output, functions and expressions;
• Understanding simple strategies like iteration, validation, sum, count, minimum, and maximum plans;
• Translating simple design into JavaScript code
• The mechanics of editing, interpreting, building, running and testing a program
• Commenting source code
• Becoming confident and comfortable with programming in small problems
Background
According to Australian Bureau of statistics, on 7 April 2018 at 12:27:29 PM (Canberra time), the resident population of Australia is projected to be: 24,896,222. This projection is based on the estimated resident population on 30 September 2017 and assumes growth since then with assumptions which are consistent with figures released in Australian Demographic Statistics, September Quarter 2017 (cat. no. 3101.0). The Australian population on 30 September 2017 are as Table 1.
Your Task
In this assignment, you will design and implement an Australian population (AP) calculator program for client that allows users to input the state/territory name and the population, then calculate the total population and average population accordingly.
Functional Requirements
The program should be implemented in JavaScript and running on Firefox, a web browser independent to operating systems. The client has specified the following requirements for the functionality of the program:
1. The program should be running without errors throughout two Phases: Information Gathering and Information Presenting.
2. Information Gathering is to gather the information such as state/territory name and the population for calculation of AP;
3. The program should first confirm with the user for willingness of entering a new state/territory before proceeding to gather information of the state/territory name and population for calculation.
4. When receiving a new entry for a state/territory, the program should first prompt and ask the user to enter the state/territory name. If the user enters nothing or an invalid state/territory name, the program should alert an error message on screen and then prompt the user to re-enter. The process should iterate until a state/territory name is entered.
5. If the entered state/territory name is valid, the program should then prompt the user to input the population for the state/territory. Again, if nothing or an invalid value is entered, the program should display an error message then iterate until receive a valid population value.
6. After valid input of state/territory name and the population, the program should loop back to seek user confirmation for either proceeding to add one more state/territory or moving to the Information Presenting phase to calculate and display the results;
7. If the user confirms no more state/territory to enter, the Information Gathering phase is completed and the program then moves to Information Presenting.
8. In the Information Presenting phase, the program prints on the web page a table containing all entered state/territory(s), including information such as state/territory name and the population.
9. To make the AP calculator user-friendly, the client also expects the program to display some statistic information:
- The number of state/territory(s) that the user has completed and entered;
- The state/territory(s) with the largest population;
- The state/territory(s) with the smallest population;
- The total population for the entered state/territory(s);
- The average population for the entered state/territory(s).
Respectively, Figure 1 and 2 illustrate the dataflow in Information Gathering and a sample result presented to the web browser in Information Presenting.
Implementation
Task 1 - A Validation Plan for state/territory name
You need to implement a validation plan to get a valid input from the user for state/territory name. A valid state/territory name needs to satisfy ALL the following criteria:
- The input should be one of the states/territories OR abbreviations (New South Wales, Victoria, Queensland, South Australia, Western Australia, Tasmania, Northern Territory, Australian Capital Territory, NSW, VIC, QLD, SA, WA, TAS, NT and ACT).
- If user have inputted New South Wales, the NSW will be an invalid input or if user have inputted NSW, the New South Wales will be an invalid input, so do other states/territories.
- The state/territory name should be case-insensitive.
Figure 1: Dataflow in Information Gathering
Task 2 - A Validation Plan for the population of entered state/territory
You need to implement another validation plan to get a valid input from the user for population of entered state/territory. A valid input needs to satisfy ALL the following criteria:
- it is a number;
- it is an integer value between 200,000 and 9,000,000.
Task 3 - An Iteration Plan for Information Gathering Phase
You need to design an iteration plan to implement the Information Gathering Phase. Refer to Functional Requirements and Fig. 1 for the detail of dataflow in iteration. Clearly, this task should incorporate the works in Task 1 and 2.
Task 4 - A Maximum Plan to find the state/territory with the largest population
Your program needs to find the entered state/territory with the largest population.
Task 5 - A Minimum Plan to find the state/territory with the smallest population
Your program needs to find the entered state/territory with the smallest population.
Task 6 - Sum, Count, Average Plans to calculate the state/territory population
Your program needs to be able to calculate the average population for all entered courses. The task includes:
- a sum plan to accumulate the population of all the entered state/territory(s);
- a count plan to count the number of state/territory(s) being entered;
- an average plan to calculate the average population of all the entered state/territory(s);
- handling the \Division by Zero" exception when calculating average.
Task 7 - Presenting the Detailed Course Information
Print to a table the detailed information of entered state/territory(s) including the state/territory name and the population.
- The state/territory(s) should be presented with all upper case letters.
- They are listed in descending order according to the population of entered state/territory(s) even the state/territory with the largest population is not entered as the first input (challenge task).
Task 8 - Presenting the Statistics
Print to an ordered list the statistic information of
- how many state/territory(s) having been entered;
- the state/territory with the largest population;
- the state/territory with the smallest population;
- the total population of entered state/territory(s);
- the average population of entered state/territory(s) and it is an integer value;
The state/territory name should be presented with all upper case letters. The table and the list should be formatted like the screenshot in Figure 2.
Figure 2: Sample Output of the Program
Program Integration Test
You need to test the program for all functionality thoroughly before delivering the program to client. The program should be running appropriately without any syntax or logic errors.
Non-Functional Requirements
• All code should appear in the script section in the head of the HTML document. Do not write any code in the HTML body. All functionality are delivered by JavaScript.
• In the script arrange your code as in the following order:
(a) Constants;
(b) Variables and objects (declared and initialized);
(c) Other statements.
• Variable and constant identifiers should follow appropriate conventions.
• Code is indented appropriately and grouped in blocks according to the common tasks attempting to.
• Appropriate comments should be added to all blocks of code. Do not simply translate the syntax into English for comments, instead, describe the purpose of the code.
Attachment:- Assignment-Specification.rar