5 Replies - 212 Views - Last Post: 14 March 2019 - 09:14 AM Rate Topic: -----

#1 DoomDemolisher   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-March 19

Loan Calculator

Posted 14 March 2019 - 08:24 AM

I am trying to create a loan calculator, this is the code I have so far, but I don't know if it is correct. I am trying to make the loan calculator in Small Basic.

 ' Loan Calculator

Textwindow.Title = "Loan Calculator"
YourName = ""
Deposit = 0.0
Months = 0
Total = 0.0

' Ask for your name

Textwindow.Write("Hello, what is your name? ")
YourName = Textwindow.Read()

Textwindow.WriteLine("")

' get deposit amount

Textwindow.Write("What is your total amount finaced? ")
Financed = Textwindow.ReadNumber()
Textwindow.WriteLine("")
' gte number of months

Textwindow.Write("What is your loan term in months? ")
Months = Textwindow.ReadNumber()
Textwindow.WriteLine("")
' Computer and Display Total

Total = Financed * Months
Textwindow.WriteLine(YourName + ", after " + months + " months, you will have $" + total + " in your account.")
Textwindow.WriteLine("")



Is This A Good Question/Topic? 0
  • +

Replies To: Loan Calculator

#2 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6737
  • View blog
  • Posts: 27,741
  • Joined: 12-December 12

Re: Loan Calculator

Posted 14 March 2019 - 08:29 AM

Run it and see what happens.
Was This Post Helpful? 0
  • +
  • -

#3 DoomDemolisher   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-March 19

Re: Loan Calculator

Posted 14 March 2019 - 08:47 AM

I ran the program with some new code, but when I run it, it always says that I will have $0 left in my account. It is supposed to calculate my account balance and interest rate.

' Loan Calculator

Textwindow.Title = "Loan Calculator"
YourName = ""
Deposit = 0.0
Months = 0
Total = 0.0

' Ask for your name


Textwindow.Write("Hello, what is your name? ")
YourName = Textwindow.Read()

Textwindow.WriteLine("")

' get deposit amount

Textwindow.Write("What is your total amount finaced? ")
Financed = Textwindow.ReadNumber()
Textwindow.WriteLine("")
' Get number of months

Textwindow.Write("What is your loan term in months? ")
Months = Textwindow.ReadNumber()
Textwindow.WriteLine("")

' Interest Rate

Textwindow.Write("What is yout interest rate? ")
Interest = Textwindow.ReadNumber()
Textwindow.WriteLine("")


' Computer and Display Total



Total = Financed * Months

Total = 1200 * (Deposit * (Math.Power((1 + Interest / 1200), Months) - 1) / Interest)

Textwindow.WriteLine(YourName + ", after " + months + " months, you will have $" + total + " in your account.")
Textwindow.WriteLine("")


Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14854
  • View blog
  • Posts: 59,272
  • Joined: 12-June 08

Re: Loan Calculator

Posted 14 March 2019 - 08:55 AM

Check your math. ARe you certain you are getting all the values in? One stray '0' times what ever still zeros it out. ;)
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6737
  • View blog
  • Posts: 27,741
  • Joined: 12-December 12

Re: Loan Calculator

Posted 14 March 2019 - 09:05 AM

Quote

it always says that I will have $0 left in my account.


I get this all the time ;)
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6737
  • View blog
  • Posts: 27,741
  • Joined: 12-December 12

Re: Loan Calculator

Posted 14 March 2019 - 09:14 AM

Note that you set Total = Financed * Months but then immediately set it to a different value. This is worth checking and removing if redundant.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1