Getting the "Invalid integer input" error and I don't know why
Author |
Message |
cactussenpai
|
Posted: Fri Mar 25, 2016 7:05 pm Post subject: Getting the "Invalid integer input" error and I don't know why |
|
|
What is it you are trying to achieve?
I am writing a program which tells a student their average if they input four marks.
What is the problem you are having?
When the program gets to where the user inputs the marks, it crashes, giving the error.
Describe what you have tried to solve this problem
I have tried changing many places of the program but to no avail.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
setscreen ("graphics:800;500")
var font1 : int := Font.New ("candara:12:bold")
var font2 : int := Font.New ("candara:12")
var font3 : int := Font.New ("times:12:italic")
var name : string
var mark1 : int
var mark2 : int
var mark3 : int
var mark4 : int
var text1 : string := "It's that time again, students. It's time for grades!! If you'd like to know your average, please follow the steps below."
put "\n"
put "\n"
put "\n"
procedure textDelayFont (text : string, x, y, font, clr, timeDelay : int)
var xPos := x
for i : 1 .. length (text )
Font.Draw (text (i ), xPos, y, font, clr )
xPos + = Font.Width (text (i ), font )
delay (timeDelay )
end for
end textDelayFont
textDelayFont (text1, 0, 450, font2, red, 50)
Font.Draw ("Please type your full name: ", 0, 425, font1, black)
get name
put "\n"
put "\n"
put "\n"
Font.Draw ("Please put your marks in percent(4 marks): ", 0, 370, font1, black)
get mark1
get mark2
get mark3
get mark4
put "\n"
var average : int := (mark1 + mark2 + mark3 + mark4 ) div 4
Font.Draw ("Your average is: ", 0, 290, font1, blue)
Font.Draw (intstr (average ), 150, 290, font1, red)
|
Please specify what version of Turing you are using
Turing 4.1.1 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dreadnought
|
Posted: Fri Mar 25, 2016 8:43 pm Post subject: Re: Getting the "Invalid integer input" error and I don't know why |
|
|
get will stop reading input at the first whitespace character. So If I enter my name as then it will only read "first" and leave the rest. The next time you call get it will resume where it left off and read "last". Since "last" isn't an integer you get an error. |
|
|
|
|
![](images/spacer.gif) |
Gaming Lyfe
|
Posted: Tue Mar 29, 2016 6:24 pm Post subject: RE:Getting the "Invalid integer input" error and I don\'t know why |
|
|
You could use the command get:*, which allows the get command to take in multiple words instead of just one.
ex.
get:* name |
|
|
|
|
![](images/spacer.gif) |
|
|