Computer Science Canada I Need Help With This Case Statement! |
Author: | master-awesome [ Tue Nov 25, 2014 8:29 pm ] |
Post subject: | I Need Help With This Case Statement! |
My question is how do I make the case statement less than 100? That's all! Quote: % A sequence of six tests, all scored out of 100, are to be given different
% weighting in determining a total mark. Write a program that first reads a % value of testNumber and score. Using a case statement it computes and then % prints the appropriate value of weightdScore, using the weightings given in % the following table. % Declared Variables var n1 : real var n2 : real var n3 : real var n4 : real var n5 : real var n6 : real var answer1 : int var answer2 : real n1 := .1 n2 := .2 n3 := .2 n4 := .15 n5 := .15 n6 := .2 % User Response put "Write down your test from 1-6: ".. get answer1 put "What was the score on that test: ".. get answer2 % Test Score Calculations case answer1 of label 1 : put "The score of ",round (answer2)," on test 1 gives a weighted score of ",answer2 * n1,"." label 2 : put "The score of ",round (answer2)," on test 2 gives a weighted score of ",answer2 * n2,"." label 3 : put "The score of ",round (answer2)," on test 3 gives a weighted score of ",answer2 * n3,"." label 4 : put "The score of ",round (answer2)," on test 4 gives a weighted score of ",answer2 * n4,"." label 5 : put "The score of ",round (answer2)," on test 5 gives a weighted score of ",answer2 * n5,"." label 6 : put "The score of ",round (answer2)," on test 6 gives a weighted score of ",answer2 * n6,"." end case |
Author: | Tony [ Wed Nov 26, 2014 12:25 am ] |
Post subject: | Re: I Need Help With This Case Statement! |
master-awesome @ Tue Nov 25, 2014 8:29 pm wrote: My question is how do I make the case statement less than 100?
If someone was to stop you on the street and ask the same question, it's likely that you wouldn't know what was being talked about. It's not a good question. The template questions of what are you trying to achieve? and what did you do to try to solve this problem? are useful in two ways -- they prompt you to think about the problem, likely getting you closer to the answer, and they give us more context to understand the problem. That is, a "case statement" doesn't have a numeric value, so I don't understand what it would mean for it to be more, less, or equals to 100. |
Author: | master-awesome [ Wed Nov 26, 2014 1:32 pm ] |
Post subject: | Re: I Need Help With This Case Statement! |
Okay I was just checking if the case statement can be less than 100, but I don't think this really matters with the teacher. Thanks for letting me know! |