Mr Green's Percentage Calculator
Mr Green, a teacher, asked a pupil to write program to calculate the percentages scored by his pupils in an exam. The exam is out of 80 marks. The program asks for the student's name and score, then outputs a percentage.
Part 1 - It Doesn't Work!
Unfortunately, the pupil was not very able, and the program won't even run. Here is the code - see if you can fix all the Syntax Errors so that it compiles.
Part 2 - Logic Errors!
Unfortunately, although it runs, it is not working properly!
Run it to see the problem. It has Logic Errors.
Fix the code so it calculates the percentages correctly. For example Sam got 41 out of 80, which should give him a percentage of 51.25.
Part 3 - Enter lots of pupils at a time
Mr Green is happy to have a program that works, but it is a bit annoying to have to run it again and again for each pupil.
It would be better to have the program continually accept new pupil names and scores unitl Mr Green was done. He could then enter a blank pupil name to show that he had finished.
Adapt the program so that:
You can test your program by checking with there pupils:Sam got 41 - 51.25%
Mary got 53 - 66.25%
Alice got 40 - 50%
Part 4 - Make it Smooth
After entering all the pupils details, it would be really helpful to have a print of all the details of all the pupils which he could copy into their reports.
He wants the printout to look like this:
Part 5 - Tidying up
Mr Green is really pleased with the program, but he has had a few ideas about improvements. He has noticed that if you enter a score which isn't actually a number, the program crashes. That can be very annoying.
Fix this problem. If the user accidentally enters an non- numeric score, make them try again until they get it right
Extension - Use a pair of arrays for grade boundaries to work out a grade.
Extension - Read the student marks from a text file instead of typing then in.