Johnnoo Williams wrote:How would i do the calculation for the initial deposit amount, monthly deposit amount and new balance for the account including interest? I'm new to java programming so i'm still a bit unsure.
Stuart A. Burkett wrote:
Johnnoo Williams wrote:How would i do the calculation for the initial deposit amount, monthly deposit amount and new balance for the account including interest? I'm new to java programming so i'm still a bit unsure.
Do you know the formula for calculating the new balance and just need to know how to implement that in Java ? Or are you asking us to tell you the formula ?
If the former, then you need to tell us what formula you are using, because there are a number of ways it could be done.
If the latter, then you should really ask your teacher because there are a number of ways it could be done so you need to find out which one they are expecting you to use.
Johnnoo Williams wrote:Anyone able to help me with this? Please?
Johnnoo Williams wrote:balance = balance + monthly deposit amount
interest = balance (current) * ((interest rate / 12) / 100)
balance (new) = balance (current) + interest
That's the formula i just need to know how i would implement that in Java.
Pawel Pawlowicz wrote:
Johnnoo Williams wrote:Anyone able to help me with this? Please?
We are helping.
Please tell us whether:
 you know how you want to calculate balance but don't know how to code it in Java (then ShowSomeEffort, show us what you tried and what you don't understand)
 you dont know how to calculate balance at all (in this case StopCoding and write it on paper first)
EDIT:
Sorry, I didn't notice you know the formula already.
Those are simple arithmetic operations. Read this tutorial: link
If you don't understand something ask about it. You need to be a little more specific about what you don't understand.
Johnnoo Williams wrote:Thanks for the link but i just don't understand how i would calculate it all for every month. For the first month would it be something like this?
System.out.println ("Balance after first month: $" + deposit + monthly);
I appreciate the help
Johnnoo Williams wrote:System.out.println ("Balance after first month: $" + deposit + monthly);
Johnnoo Williams wrote:but i get errors.
Johnnoo Williams wrote:Thanks so much for the help guys i got the everything working except for the interest. I'm not sure what i'm doing wrong i was trying to do it similar to what i did with the other 2 but i get errors. Here is the code:
There are only two hard things in computer science: cache invalidation, naming things, and offbyone errors
Johnnoo Williams wrote:Here are the errors,
MenuDrivenProgram.java:91: ')' expected
interest = deposit (current) * ((interest rate / 12) / 100);
^
MenuDrivenProgram.java:91: ';' expected
interest = deposit (current) * ((interest rate / 12) / 100);
^
MenuDrivenProgram.java:92: <identifier> expected
deposit (new) = deposit (current) + interest;
^
MenuDrivenProgram.java:92: ')' expected
deposit (new) = deposit (current) + interest;
^
4 errors
Pawel Pawlowicz wrote:
Johnnoo Williams wrote:Here are the errors,
MenuDrivenProgram.java:91: ')' expected
interest = deposit (current) * ((interest rate / 12) / 100);
^
MenuDrivenProgram.java:91: ';' expected
interest = deposit (current) * ((interest rate / 12) / 100);
^
MenuDrivenProgram.java:92: <identifier> expected
deposit (new) = deposit (current) + interest;
^
MenuDrivenProgram.java:92: ')' expected
deposit (new) = deposit (current) + interest;
^
4 errors
So, this is what I thought. See my previous post .
BTW, for this you don't need to introduce a new variable. Just use the once you've already got. A deposit.
Johnnoo Williams wrote:interest = currentDeposit (current) * ((interest / 12) / 100);
currentDeposit (new) = currentDeposit (current) + interest;
Johnnoo Williams wrote:Still not working i keep getting the same 4 errors.
Also do you mean i should change that value that says (new)?
EDIT: Okay i removed "new" and changed it to something else but i still get these 2 errors,
MenuDrivenProgram.java:91: ')' expected
interest = currentDeposit (current) * ((interest rate / 12) / 100);
^
MenuDrivenProgram.java:91: ';' expected
interest = currentDeposit (current) * ((interest rate / 12) / 100);
^
2 errors
Show us your code and the error messages, so we can tell you what else might be wrong.Johnnoo Williams wrote:Yeah i've changed all the variables and made sure they aren't key java variable names but when i change interest rate i get more error messages.
I really don't know what to do here i've tried not coding and thinking about all this but it isn't working :/
Johnnoo Williams wrote:Can you tell me what i should name them? Please?
Johnnoo Williams wrote:Got these 4 errors now. :/
MenuDrivenProgram.java:91: cannot find symbol
symbol : variable balanceCurrent
location: class MenuDrivenProgram
interest = balanceCurrent * interestRate / 12 / 100;
^
MenuDrivenProgram.java:91: cannot find symbol
symbol : variable interestRate
location: class MenuDrivenProgram
interest = balanceCurrent * interestRate / 12 / 100;
^
MenuDrivenProgram.java:92: cannot find symbol
symbol : method deposit(int)
location: class MenuDrivenProgram
deposit (deposit) = balanceCurrent + interest;
^
MenuDrivenProgram.java:92: cannot find symbol
symbol : variable balanceCurrent
location: class MenuDrivenProgram
deposit (deposit) = balanceCurrent + interest;
^
4 errors
No, tomorrow we rule the world! With this tiny ad:
how do I do my own kindlelike thing  without amazon
https://coderanch.com/t/711421/engineering/kindleamazon
