Computer Science Canada Report Card Program (IF/ELSIF CONDITIONS and CASE STATEMENTS) |
Author: | Loomis [ Sat Oct 31, 2009 4:19 pm ] | ||||
Post subject: | Report Card Program (IF/ELSIF CONDITIONS and CASE STATEMENTS) | ||||
What is it you are trying to achieve? I'm trying to make a program that asks for a person's name, the names of four courses that she take and the mark she recieved for each course. Then, the program should calculate the person's average to one decimal place and determine how many credits the person has earned and output an attractively designed report card. What is the problem you are having? The problem is that I can't seem to use the if/elsif conditions or a case statement to make the program output how many credits they've earned. Describe what you have tried to solve this problem This is what I have so far :
Well, it's obvious that it doesn't work correctly and the style is really bad. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) This is the whole program:
How can I make the program correctly calculate the credits earned and how can I make the report card design more attractive and the codes more user friendly? Please specify what version of Turing you are using Version 4.1.1 |
Author: | Superskull85 [ Sat Oct 31, 2009 5:29 pm ] | ||||
Post subject: | Re: Report Card Program (IF/ELSIF CONDITIONS and CASE STATEMENTS) | ||||
The problem is that you have grouped your if statements together; you will never reach branch two unless branch one failed, etc. What you want to have are separate, non-grouped, if statements for each mark. For example the way you did it was:
If you wanted to check all marks you would need to have separate if statements:
This way each mark is checked even if the first check comes true. ![]() |
Author: | Loomis [ Sun Nov 01, 2009 7:43 pm ] |
Post subject: | Re: Report Card Program (IF/ELSIF CONDITIONS and CASE STATEMENTS) |
Oh, I completely understand! Thanks a bunch. ![]() |
: |