10 Replies - 609 Views - Last Post: 28 March 2019 - 03:39 AM Rate Topic: -----

#1 DoomDemolisher   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • 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

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,942
  • 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: 4
  • 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: 14925
  • View blog
  • Posts: 59,591
  • 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

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,942
  • 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

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,942
  • 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
  • +
  • -

#7 DoomDemolisher   User is offline

  • New D.I.C Head

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

Re: Loan Calculator

Posted 27 March 2019 - 08:42 AM

I am still stuck on trying to create a loan calculator with small basic. I have now tried it with some new code, but am still getting the wrong amount in the end. Thank you in advance.
Textwindow.Title = "Loan Calculator V2"

'  Ask for your name


Textwindow.Write("Type your name here:  ")
name = Textwindow.Read()

Textwindow.WriteLine("")



' Ask for principal amount

Textwindow.Write("What is your principal amount?  ")
P = Textwindow.Read()

Textwindow.WriteLine("")

' Ask for loan term in months

Textwindow.Write("What is your loan term in months?  ")
N = Textwindow.Read()

Textwindow.WriteLine("")

' Ask for interest rate

Textwindow.Write("What is your interest rate>  ")
I = Textwindow.Read()

Textwindow.WriteLine("")

' Variables


V1 = 1 + I
V2 = Math.Power(V1, N)
V3 = V2 - 1
V4 = I * V2

'  Actual Math
D = V3/V4


mp = P/D
T = mp * N


TI = T - P

' Stuff

Textwindow.WriteLine( TI )



This post has been edited by andrewsw: 27 March 2019 - 08:45 AM
Reason for edit:: fixed botched [code][/code] tags

Was This Post Helpful? 0
  • +
  • -

#8 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,942
  • Joined: 12-December 12

Re: Loan Calculator

Posted 27 March 2019 - 08:45 AM

Which wrong amount? For what input and for what expected output?
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14925
  • View blog
  • Posts: 59,591
  • Joined: 12-June 08

Re: Loan Calculator

Posted 27 March 2019 - 08:46 AM

what is your input?
What is your output?
What is your expected output?
Are there any error messages you should copy/paste here?
Was This Post Helpful? 0
  • +
  • -

#10 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6776
  • View blog
  • Posts: 27,942
  • Joined: 12-December 12

Re: Loan Calculator

Posted 27 March 2019 - 08:47 AM

Merged topics so that we know what you mean with "I am still stuck".
Was This Post Helpful? 0
  • +
  • -

#11 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 370
  • View blog
  • Posts: 1,586
  • Joined: 07-September 13

Re: Loan Calculator

Posted 28 March 2019 - 03:39 AM

Why did you replace your well written and self-documenting variables for random v's? Which means nothing to no one?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1