I have a problem and i just need a little help with it. The purpose of this portion of the code is to determine how much the cost of healthcare will be for a student. The healthcare system works like this:
For the first 10 credits, the price is $25 per credit. For the next 5 credits, the price is $20 per credit added on to the price before. For 15 or more credits, the price is $15 per credit added on to the price before as well.
I have this much code so far:
if(credit <= 10)
hCare = 25 * credit;
else if(credit >= 10 && credit <= 15)
hCare = 20 * credit;
else if(credit > 15)
hCare = 12 * credit;
I get it to add each credit but i need it to add the previous hCare value where hCare is a private double. Can somebody help me???
The logic is simply how you would solve this on paper. Do that, and the code will follow quite easily. I'm dead serious here.
i tried doing that and I'm still stuck. I guess I'm a total noob...
One way, use a for loop to loop through each credit and add to a total cost variable an amount depending on the current index value of the loop.
Another way, if credits > 10, figure out how much the first 10 credits add to cost and add that to total, then add the others based on the formula...
This really isn't a Java question, or even much of a math question, but more of a basic sit and think question. You can do it!