문제

Hello I just started using small basic and there is a simple program that I compiled but something is wrong.

 Total = ((Loan*Loanp/100)+Expense)-Salary
TextWindow.WriteLine("Your Loan: ")
Loan = TextWindow.ReadNumber() 
TextWindow.WriteLine ("Your Loan %: ")
TextWindow.ReadNumber(Loanp)
TextWindow.WriteLine ("Your Expense: ")
Expense = TextWindow.ReadNumber()
TextWindow.WriteLine ("Your Salary: ")
Salary = TextWindow.ReadNumber()
If (Loan*Loanp/100)+Expense > Salary Then
  TextWindow.WriteLine ("Error : You are FOREVER in loan")
Else
  TextWindow.WriteLine ("You savings are "+Total)

EndIf

the answer is always zero. when I try to set a number to "Total" then It works Eg.

Total = 100*3/100+50
TextWindow.WriteLine("Your Loan: ")
Loan = TextWindow.ReadNumber() 
TextWindow.WriteLine ("Your Loan %: ")
TextWindow.ReadNumber(Loanp)
TextWindow.WriteLine ("Your Expense: ")
Expense = TextWindow.ReadNumber()
TextWindow.WriteLine ("Your Salary: ")
Salary = TextWindow.ReadNumber()
If (Loan*Loanp/100)+Expense > Salary Then
  TextWindow.WriteLine ("Error : You are FOREVER in loan")
Else
  TextWindow.WriteLine ("You savings are "+Total)
EndIf
도움이 되었습니까?

해결책

You are using the values of 'Loan', 'Loanp', Salary and Expense (to compute Total) before you have read them in! You need to move the line that computes Total to somewhere after the line where you read in the value, e.g., after Salary = TextWindow.ReadNumber().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top