The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

am I going to use if / loops in this java work?

hi i have an assignment but I am way ahead in class, so i usually jump ahead but I am not sure what I going to be doing here

this is the assignment. I tried looking in my notes, but cant manage to figure out what to do. Maybe osmeone can tell me what ill be using here ( i know booleans ill be using) but I am just trying to use my notes as a guide

_____________________________

The XYZ School wants to carry its grade 10 students on a trip. The cost of the trip is $5,000.00. The school has only thirty days in which to collect the funds in order to go on the trip.

Design a class called SchoolContribution that creates a contribution account. Incorporate the following:

• A method called totalContribution(..) that accepts and accumulates the daily contributions.
• A Boolean method called hasMoreTime() that determines if more time is available in which to reach the targeted amount.
• A Boolean method called needMoreMoney() that determines if more contribution is needed to meet the target.
• A Boolean method called metTarget() that reports if target has been met. This must be based on meeting the target within the time frame.
• A method called toString() that returns the result.

Write a test class called TestContribution that generates the daily contributions. It keeps making contribution until it determines that either the targeted amount of contribution is met, or the time allotted to collecting the amount of money expires. In either case it displays the amount of money collected each day, and the total amount accumulated over the period.

Re: am I going to use if / loops in this java work?

Originally Posted by willc86

hi i have an assignment but I am way ahead in class, so i usually jump ahead but I am not sure what I going to be doing here

this is the assignment. I tried looking in my notes, but cant manage to figure out what to do. Maybe osmeone can tell me what ill be using here ( i know booleans ill be using) but I am just trying to use my notes as a guide

_____________________________

The XYZ School wants to carry its grade 10 students on a trip. The cost of the trip is $5,000.00. The school has only thirty days in which to collect the funds in order to go on the trip.

Design a class called SchoolContribution that creates a contribution account. Incorporate the following:

• A method called totalContribution(..) that accepts and accumulates the daily contributions.
• A Boolean method called hasMoreTime() that determines if more time is available in which to reach the targeted amount.
• A Boolean method called needMoreMoney() that determines if more contribution is needed to meet the target.
• A Boolean method called metTarget() that reports if target has been met. This must be based on meeting the target within the time frame.
• A method called toString() that returns the result.

Write a test class called TestContribution that generates the daily contributions. It keeps making contribution until it determines that either the targeted amount of contribution is met, or the time allotted to collecting the amount of money expires. In either case it displays the amount of money collected each day, and the total amount accumulated over the period.

So you have a description of the problem to solve, and some requirements for the solution.

public class //Design a class called SchoolContribution that creates a contribution account.
A method called totalContribution(..) that accepts and accumulates the daily contributions.{
}
A Boolean method called hasMoreTime() that determines if more time is available in which to reach the targeted amount.{
}
A Boolean method called needMoreMoney() that determines if more contribution is needed to meet the target.{
}
A Boolean method called metTarget() that reports if target has been met. This must be based on meeting the target within the time frame.{
}
A method called toString() that returns the result.{
}
}

See how the steps are pseudo code if you just organize them... Take one method at a time and break it down into more steps. Consider the first method, totalContribution(..)
A method called totalContribution(..) that accepts and accumulates the daily contributions.
-method must accept numeric type
-must keep track of a numeric type between method calls in order to accumulate each individual value into a total

Get this method, or which ever method you choose to do first, working before worrying about the other methods. Get the class to compile and run and test the method. When it is working, move to the next one. It is hard to offer much advice without seeing how far you can get on your own. See what you can get and ask more questions when you get stuck.

Re: am I going to use if / loops in this java work?

I think you misunderstood the concept of the method. In a variable, say totalContribution, you would store the total. The method is supposed to accept and accumulate the daily contributions, not the totalContribution. The daily contributions need to be added to the totalContribution every time there is a single donation.