Computer Science Canada Can someone tell me what I am doing wrong? |
Author: | 5pirit [ Mon Feb 13, 2012 3:57 pm ] |
Post subject: | Can someone tell me what I am doing wrong? |
Hey guys I am new to Turing and I was wondering what I am doing wrong in this program? I keep getting an error. This is the program: % This program was created by... % This program was created on feb 13th % This program calculates your average on 5 tests and outputs the percentage for each test % declare variables var test1 : int var test2 : int var test3 : int var test4 : int var test5 : int var name : string var percentontest1 : int var percentontest2 : int var percentontest3 : int var percentontest4 : int var percentontest5 : int var test1markoutof : int var test2markoutof : int var test3markoutof : int var test4markoutof : int var test5markoutof : int var average : int var winID : int % create window winID := Window.Open ("position:top;left, graphics:800;600") View.Set ("title:Window One") % get user info put "Hello! This program will calculate your average on 5 tests and your percent on each of those tests!" .. delay (1500) put "Firstly, I need to know your name!" .. get name : * put name, ",what was test 1 out of?" .. get test1markoutof put "Now I need to know your mark on test 1,", name get test1 put name, ",what was test 2 out of?" .. get test2markoutof put "Great!" put name, ",what was your mark on test 2?" .. get test2 put name, ",what was test 3 out of? Enter it now" .. get test3markoutof put "Now...enter your mark on test 3,", name get test3 put name, ",what was test 4 out of?" get test4markoutof put "Enter your mark on test 4,", name get test4 put "Almost done,", name put name, ",what was test 5 out of?" .. get test5markoutof put "Now finally, what was your mark on test 5?,", name get test5 % formulas percentontest1 := test1 / test1markoutof percentontest2 := test2 / test2markoutof percentontest3 := test3 / test3markoutof percentontest4 := test4 / test4markoutof percentontest5 := test5 / test5markoutof average := percentontest1 + percentontest2 + percentontest3 + percentontest4 + percentontest5 / 5 % output results put name, ",your mark on test one was" delay (500) put percentontest1, "%" put name, ",your mark on test two was" delay (500) put percentontest2, "%" put name, ",your mark on test three was" delay (500) put percentontest3, "%" put name, ",your mark on test four was" delay (500) put percentontest4, "%" put name, "your mark on test five was" put percentontest5, "%" put name, "your overall average is" .. delay (1000) put average |
Author: | Tony [ Mon Feb 13, 2012 4:01 pm ] |
Post subject: | RE:Can someone tell me what I am doing wrong? |
Moved from General Programming, so it's missing "the template". What is the error? How did you investigate it? |
Author: | 5pirit [ Mon Feb 13, 2012 4:10 pm ] |
Post subject: | Re: Can someone tell me what I am doing wrong? |
I am getting an "assigned value is the wrong type" error. I have no clue what it means but its happening in the formula section. |
Author: | Tony [ Mon Feb 13, 2012 4:41 pm ] |
Post subject: | RE:Can someone tell me what I am doing wrong? |
It means that the type of the variable (integer, string, etc.) is different from what you are trying to save there. |
Author: | mobin12 [ Mon Feb 13, 2012 5:36 pm ] | ||||||
Post subject: | RE:Can someone tell me what I am doing wrong? | ||||||
you should define it as a 'real' instead of 'int' So
the variables should be
'int' means it will be a whole number 'real' means it will be in decimals Also you should multiply the 'perctontest' by 100
Hope that helped. |
Author: | Raknarg [ Mon Feb 13, 2012 6:43 pm ] |
Post subject: | RE:Can someone tell me what I am doing wrong? |
In case you were wondering why, it's because you are trying to assign a value with a decimal to a variable that only supports whole numbers |
Author: | 5pirit [ Mon Feb 13, 2012 8:17 pm ] |
Post subject: | RE:Can someone tell me what I am doing wrong? |
Thank you so much! |