我20年后再次回到Qbasic ...... 我试图将值改变几次,具体取决于输入。 这是一个非常新手的应用程序,我确信这是一个简单的答案,但这是在揉搓我的大脑。
我希望CREDIT以+10或-10更改并在之后更改CREDIT。现在如果我按B它只减去-10一次(结果CREDIT 90),它保持在90.我希望CREDIT每次都改变,根据我选择的输入。 让我们说我第一次按B,结果是CREDIT 90.之后它会回到第101行,这样我就可以选择是否再次想要B或S,所以如果我再次选择B,我想要信用证为80.它只是保持在90.它当然是相同的但是如果我选择S(结果CREDIT 110)则添加。
代码:
1
CLS
credit = 100
sell = credit + 10
buy = credit - 10
101
CLS
PRINT " (Q)uit"
PRINT " Your credit: "; credit
PRINT: PRINT
INPUT " (B)uy for 10 or (S)ell for 10"; bs$
bs$ = LCASE$(bs$)
IF bs$ = "b" THEN GOTO 2
IF bs$ = "s" THEN GOTO 3
IF bs$ = "q" THEN END ELSE GOTO 101
2
credit = buy
GOTO 101
3
credit = sell
GOTO 101
感谢您的帮助!
答案 0 :(得分:1)
借记/贷记价值的代码:(编辑:02-12-2018)
REM sample to adjust credit value
credit = 100
buy = 10
sell = 10
DO
PRINT "Your credit: "; credit
PRINT " (B)uy for"; buy; "(S)ell for"; sell; "(Q)uit";
INPUT bs$: bs$ = LCASE$(bs$)
IF bs$ = "b" THEN credit = credit + buy
IF bs$ = "s" THEN credit = credit - sell
IF bs$ = "q" THEN END
LOOP
END
答案 1 :(得分:1)
我用你的代码做了一些事情,认为它会成为一个超级简单的高分榜。我遗漏了一些明显的东西,因为没有错误,只有打印:
highscore:One 0 Two 0
REM highscore sample for QB64, edit:
' assign variables
one = 1
two = 2
' in this case the players final credit is 25000 = X
X = 25000
' current highscore list (this is values that i want to be saved when app closes)
A = 1234
B = 12
'DO ' i don't think i need do/loop for this, right?
IF X > A THEN X = one
IF X < A THEN X = two
PRINT "highscore:"
PRINT
PRINT "One: "; one ' shouldn't this print "One: 25000"?
PRINT "Two: "; two ' and this "Two: 0"?
END
我只是不明白为什么这不起作用!?
答案 2 :(得分:0)
这是一个用于计算信用的改进菜单功能:
def outputlist(list):
for list_output in list:
print(list_output,end=" ")
return list_output
def main():
month = ["January", "February", "March", "April", "May", "June", "July", "August", "Setemper", "October", "November", "December"]
print("The list of the months of the year are:", outputlist(month))
main()
答案 3 :(得分:0)
我不确定高分是什么意思,但这段代码比较了最高价值的输入:
REM highscore sample for QB64:
DO
PRINT "Enter value";: INPUT X
IF X = 0 THEN EXIT DO
IF X > V THEN V = X
LOOP
PRINT "The highest value was:"; V
END