Pardon me if this isn’t the right place to ask but I need to make a compound-interest calculator, as a small high school project… with the feature that will help show the increase of investment over time
I just need to get the first part over with it…
Savings Simulator
Enter you initial investment: 600.00
Let’s invest your money
Interest Rate: 5
Number of years: 2
Year 1 $630.00
Year 2 $661.50…
https://docs.google.com/document/d/1Cebi50BQlEwuRnMG79TDZ178CHWMDTNIxN82b1xdASc/edit
Do you have any code written? Generally speaking people are willing to help but won’t write your project for you.
Uh I had to copy admittedly from Bro Code but here…
https://replit.com/@354075897/CompoundInterest#main.py
It’s basic but understandable and functions as usual… the thing is I need to show progress over time…
So what does it do wrong? or what do you need actual help with? What have you tried?
I need to show the sum increasing over time… just look at my example in my post over there, ight…
To be teen again and don’t know how to ask for help on the internet.
I took the code you posted and then asked the free version of ChatGPT to do what you asked and got working code immediately. I would go that route.
Do you understand how compound interest work ? If yes write it down on a paper, and the code will flow. I don’t think we’ll be helping you on the long term by doing your homework.
Well, ok, from memory
Correct me if I’m wonrg…
So how did you end up with an assignment like this while apparently knowing little if any python? This feels like someone signed up for a class, blew it off, and now suddenly has tests and stuff to turn in.
Well, I was trying to learn in g-10, at the start (when I was in-class, not online) , I had some previous computer classes before (I did Virtual Basics and Scratch, html even) but I didn’t do Python (and this is supposed to be an intro, regardless of previous experience) … wtf you expect me to do?
Plus, why do you assume this of me?
Because I’ve never seen a python class before that was ‘no experience required’ where they go “Well, normally we’d teach you about variables, and loops, functions and operator precedence…but you know what? Screw all that. Head first! YOLO! Write me some code.”
If that is how that class is, I’d drop it and go hit youtube or something. How to Learn Python stuff is pretty available if you want to learn (and python is pretty useful).
Do your own homework!
What’s your question?
def calculator(initial, rate, years): Return initial *(1 + rate/100)**years
Calculator(600, 5, 2)
Thanks, but my project requires also the results between the first and the last year the investment was increased…
As a base, I’m testing $600, 5% interest, and 6 years to wait, so I need to show the amount for years 1-5 as output, before I see final result of the 6th year…
I can’t just put:
total1 = principle * pow((1 + rate/100), 1)
print(f"Balance after {1} year/s: ${total1:.2f}")
total2 = principle * pow((1 + rate/100), 2)
print(f"Balance after {2} year/s: ${total2:.2f}")
total3 = principle * pow((1 + rate/100), 3)
print(f"Balance after {3} year/s: ${total3:.2f}")
You need a for loop like
For year in range(1, years):
Run your code here
My advice is these new AI’s seem to be able to code given the right prompt, if it was me I’d try there for ideas.