Let us imagine that a human facilitator is equipped with a laptop, and is surveying people. The facilitator will use your program to:-
Diagram 1: The Three Parts of your Code. see image.
Your program has 3 phases, as shown in the diagram above:-
Please dont allow these phases of your code to bleed into each other. The input phase should do input only. The calculation phase should perform intermediate calculations only. The display phase should display calculated data only.
Diagram 2: The Input Phase. see image.
Your program must allow the facilitator to keep entering the detail for another person until the facilitator no longer wishes to. How you achieve that is up to you, but it must be easy to use and you need to make sure the user knows what to do.
You must perform interactive input by using the prompt() function (and possibly the confirm() function).
Diagram 3: The Question Structure. see image.
For each person that the facilitator chooses to enter, you need to get the following from the user:-
The facilitator (or your marker) should require no training prior to using your program. Make it clear to the facilitator what input would be valid. Keep it simple.
E.G. "What color is your car? Enter either the string "black" or the string "white"?
E.G. If you make it so that entering an empty string for a surname is what terminates the input loop, then make sure that is obvious to the user.
You should use the method trim() to remove leading or trailing spaces from user input.
The calculation phase begins when the input stage is finished, and the display phase happens when the calculations have been performed. Your program must calculate the following collective data:-
Your output will be written to the document using document.write() or document.writeln(). The use of alert() is not acceptable, and any occurrences of console.log() will be assumed to be debugging.
Otherwise, your program must output the following:-
If your dataset is the empty set, then this must be stated.
1. The code needs to be indented in one of
2. The indentation needs to be consistent throughout the code. One of the above styles needs to be applied to all of your code. It is permissible to mix Horstmann and Allman styles.
Your code needs to be block commented throughout:-
Naming conventions should be observed for identifiers:-
You must demonstrate control over your value types:-
Your code should be executed in strict mode. I.E. It needs to have "use strict"; directive at the start of your < script > section.
Variables need to be declared (possibly with initialisation) before they are used.
The following are challenges. They are meant to be challenging, and the marks here are definitely not "low hanging fruit", offering few marks for much work. Even so, you cannot get a "high distinction" in the assignment without attempting at least one of them.
It is recommended that you only attempt these if you have finished the non-challenge parts and are confident with your program thus far. Don't forget to save a working copy of what works.
This challenge will give experience sorting an array of records and using a custom comparison function to achieve that.
As part of the calculation phase, sort the records using the surname as a primary field, and the given name as a secondary field. Your marker will be able to view the sorted records in the tabular output of your program.
This challenge will give experience in extracting components from a string as well as extra validation experience.
In place of "years of age" you should request the date of birth.
It is suggested that you write a function called getDate() that performs the input and validation of a date.
Diagram 4: The Expanded Employment Status. see image.
The entry of the employment status given above is simplistic. This challenge introduces a more realistic determination of employment status.
The entry of the employment status is to be expanded:-