Computer Science Canada VAR topic |
Author: | nin [ Tue Nov 28, 2006 6:13 pm ] |
Post subject: | VAR topic |
I need help on this one my code is not working at all there is an error and i dont noe how to fix it 0.o..... the error is bolded and underlined.... the program needs to convert distance to miles or yards and it says on the paper "You may need to errortrap the input!"... and we cant use mod ... _____________________________________________________________ %This program will convert a distance from miles to yards or yards to miles %Declaration statement var mOry : string var yOrm : string var distance : real var answer : real var number : real %Program Title locate (1, 34) put "Converter" %Program introduction locate (3, 1) put "This program allows you to convert distance to miles or yards." %User Input and errortrap locate (5, 1) put "When you enter the type of measurement, please put either m or y." put "m being miles and y being yards." locate (7, 1) put "Make sure that m or y is not capitalize." locate (9, 1) put "Please enter the type of measurement, m or y: " .. get mOry locate (10, 1) put "Please enter the distance: " .. %Processing if mOry = "m" or mOry = "M" then answer := number * 1760 mOry := "miles" yOrm := "yards" else answer := number / 1760 mOry := "yards" yOrm := "miles" end if |
Author: | Ultrahex [ Tue Nov 28, 2006 6:47 pm ] |
Post subject: | |
if you havent noticed yet the error is "Variable Has No Value" This means one of the variables it is setting to has no value yet (in your case NUMBER has not been set to anything) you are missing your get number after asking for the distance Hope This Helps |
Author: | uberwalla [ Tue Nov 28, 2006 6:50 pm ] | ||||
Post subject: | |||||
is this what you mean? ...
the error in your code is that u never got the distance and never put it to output either. also...
those two lines are kind of pointless 1) you dont even ever use them 2) u can reuse distance as u can see in what i did. so i hope this is what u were needing help with/looking for. |
Author: | nin [ Tue Nov 28, 2006 8:28 pm ] |
Post subject: | |
thank you umberwalla =) and the person above umberwalla.... =D |
Author: | uberwalla [ Tue Nov 28, 2006 8:30 pm ] |
Post subject: | |
its "uberwalla" but your welcome ![]() and its "Ultrahex" ![]() |