You are expected to produce a program that meets the following requirements.
A small record label wishes to know more about the people that buy music from it. It has created a survey for it's customers and it now needs to analyse that data using a computer program.
The program will be run so that 10 users can insert their own information. The program will then analyse the information given to it and calculate an average.
They have hired you to develop this program.
The data collected by the survey is shown below:
Name | Score |
---|---|
Fiona Barbour | 65 |
Ahmed Schall | 70 |
David Wheeler | 46 |
Beth MacCallum | 98 |
Findlay Peterson | 87 |
Brian Wilson | 96 |
Euan Tobin | 87 |
Emma Wilson | 100 |
Patrick Heller | 43 |
Hamish Peters | 12 |
Hamish Branan-Horobin | 92 |
Gael Roberts | 5 |
The program - design
In this first step, you are expected to create a flow chart of this program. Once you have done this, show this to your teacher.
Setup
You are now going to begin writing the code for the program.
Create and set up your variables. You will need variables such as an array to store the user's feedback whilst the program is running.
What other variables might you need?
Collect the data from the user
The program should first of all ask the user to insert what percentage each user gave in the survey. Use the table shown previously for the data.
You should create an input validation loop like the one shown below to ensure that the user types in a number between 0 and 100.
print("Please insert your username") username = input() print("Please insert your password") password = input() while username != "maggie" or password != "glenn": print("Incorrect username and password combination provided") print("Please reenter your username") username = input() print("Please reenter your password") password = input()
Dim username As String = InputBox("Please insert your username") Dim password As String = InputBox("Please insert your password") While Not(username = "maggie") Or Not(password = "glenn") MsgBox("Incorrect username and password combination provided") username = InputBox("Please reenter your username") password = InputBox("Please reenter your password") End While
Analyse the data
The program should now run through the percentages array, counting the number of them that are below 50.
At the end of running through the array again, it should display how many people gave percentages less than 50.
moreThan50
and then inside your loop just check if the percentage is less than 50 and add 1 to
the moreThan50
variable if it is.
Display the average
The program should now display the average. The average is calculated by adding all the percentages together then dividing them by 10.
When displaying the value, round it to no decimal places.
Test and document your program
Test your program by debugging it, testing a range of different values.
Ensure you have commented your code nicely.