VAR topic
Author |
Message |
nin
|
Posted: 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 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Ultrahex
|
Posted: Tue Nov 28, 2006 6:47 pm Post subject: (No 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 |
|
|
|
|
|
uberwalla
|
Posted: Tue Nov 28, 2006 6:50 pm Post subject: (No subject) |
|
|
is this what you mean? ...
code: |
var mOry : string
var yOrm : string
var distance : real
locate (1, 34)
put "Converter"
locate (3, 1)
put "This program allows you to convert distance to miles or yards."
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: " ..
get distance
if mOry = "m" or mOry = "M" then
put distance, " Miles Equals " ..
distance := distance * 1760
put distance, " Yards."
else
put distance, " Yards Equals " ..
distance := distance / 1760
put distance, " Miles."
end if
|
the error in your code is that u never got the distance and never put it to output either.
also...
code: |
var answer : real
var number : real
|
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. |
|
|
|
|
|
nin
|
Posted: Tue Nov 28, 2006 8:28 pm Post subject: (No subject) |
|
|
thank you umberwalla =) and the person above umberwalla.... =D |
|
|
|
|
|
uberwalla
|
Posted: Tue Nov 28, 2006 8:30 pm Post subject: (No subject) |
|
|
its "uberwalla" but your welcome
and its "Ultrahex" he has a name too |
|
|
|
|
|
|
|