Question

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
Était-ce utile?

La solution

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().

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top