如果输入负数,则需要设置加班时数为0,如果加班时数大于20,则设置为20。
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我相信我做错了,但我不知道如何修复它。
发布于 2015-04-08 11:42:53
我对smallbasic一无所知,但这里有一个简单的逻辑
假设您希望输入数字为负数时设置overtime=0,输入数字大于20时设置overtime=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发布于 2015-04-15 07:17:57
你可以做的是,做两个if语句,
if overtime<0 then
overtime = 0
else if overtime > 20 then
overtime = 20
endifendif
https://stackoverflow.com/questions/29504880
复制相似问题