Reputation: 1
I need to set overtime hours to 0 if a negative number is entered and if the overtime hours is greater than 20 set it to 20. I entered it as follows
TextWindow.Write(" Enter the number of overtime hours: ")
overtime = TextWindow.ReadNumber()
If (overtime < 0 Or overtime > 20) Then
TextWindow.WriteLine("Invalid hours. Hours must be between 0 and 20")
EndIf
I believe I'm doing it wrong but I do not know how to fix it.
Upvotes: 0
Views: 118
Reputation: 155
what you could do is, make two if statements,
if overtime<0 then
overtime = 0
else if overtime > 20 then
overtime = 20
endif
endif
Upvotes: 1
Reputation: 6738
I don't know anything about smallbasic but here is simple logic
Assuming you want to set overtime=0
when entered number is negative and overtime=20
when entered number is greater than 20;
If (overtime < 0 ) Then
TextWindow.WriteLine("Invalid hours. Hours must be greater than 0")
overtime =0
Else If (overtime > 20 ) Then
TextWindow.WriteLine("Invalid hours. Hours must be less than 20")
overtime =20
Else
//do your stuff here
EndIf
Upvotes: 1