Chris Maske

Greenhorn
+ Follow
since Mar 29, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Maske

I just solved my own problem:

10 years ago
Okay so I used "account" and "MonetaryValue" synonymously.

This MonetaryValue class is what stores the dollar and cent amounts, it's what calculates the added interest, it's what adds the monthly deposit to the main account, and it's what outputs the final dollar value for the account each month.

So here's what I have coded in MonetaryValue so far:



My whole problem is with trying to figure out how to write the code for the method on line 44.

So in the main method class I have it coded to create two MonetaryValue objects, one named balance and one named deposit:



And then later in the main method I have it set up to where it takes the deposit object and adds it to the balance object:



So basically... I just need to figure out how to write the add method in my MonetaryValue class. I'm really sorry for all the confusion on this.
10 years ago

Aj Prieto wrote:First off, read this WhatNotHow.

Next, I'm curious, why not just use doubles?

That way, you don't have to deal with multiple numbers. All you'd do is manipulate one value rather than two.




Well I actually did try to use doubles, but then when I got to class our instructor told us we couldn't

Pseudo code solution (main method of application class):

Prompt user for input values
Read input values

Create MonetaryValue object for the balance of the account
Set the value of the object with the start dollar and cents values ..........................setValue()

Create MonetaryValue object for the amount to deposit each month
Set the value of the object with the dollar and cents values for monthly deposit .....setValue()

Repeat for correct number of years
Repeat for the correct number of months

Add interest to the balance ..............................................................................addInterest()

Add the monthly deposit amount to the deposit ..................................................add()

Display the new balance



So above is the solution that he wants us to use in order to solve the problem. And I also should have mentioned that I do have an addinterest method in my class. I've pretty well got the whole code finished except for that one add method... and he wants us to do it like this:


"add the addend dollars and the addend cents to the dollars and cents of the object"

All thoughts, ideas, comments, are much appreciated up to this point and after.
10 years ago
In my java class my instructor is wanting us to create a program that calculates the amount of interest accrued on an account per year and displays the amount that is in that account every month.

So a sample runtime of this is as follows:

In the main method I create two classes, one for the balance account and the other for the monthly deposit.

So I have two objects of the same class.

Then I'm asked to enter the amount for the first object which I'll call the "balance."
Then I enter the dollar amount separated by a space and the cent amount for the balance.
The balance object then takes these two values and stores them to two separate variables, one for dollars and one for cents.

Then I enter the deposit amount.
and it does the same as above.

Then i enter the percentage of the interest rate.

Then I enter how many years I want it to run for.

Then it goes into a for-loop structure.

In the body of the loop, it first calculates the amount of interest that will be added to the balance.

then it adds the new balance to the deposit object

and then it outputs the total amount of the balance, and then loops through it again.

My issue is adding the balance object to the deposit object.
I have a method in this account class called "add" and so far I know that the structure should look something like this:

public void add(MonetaryValue addend)
{
(But I have no idea what goes here or how to get this to work.)
}

Can anyone help me? Thanks!
10 years ago