File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Using several IF-statements to calculate Packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using several IF-statements to calculate Packages" Watch "Using several IF-statements to calculate Packages" New topic

Using several IF-statements to calculate Packages

Alejandro Loaiza

Joined: Sep 13, 2013
Posts: 9
So I'm on my last part of my assignment and I'm stuck on constructing a customers monthly statement if they go over the specific amount of hours they chose from the Packages and it would display the amount of money they would have saved if they chose Package B or Package C. That's only if they go over the hours. In my code, I seem to not be able to use:

if (hours < baseHours) from my internetServiceCharges() so I can calculate. The assignment question is this :

4. Challenge 14: The modifications to your program should be made entirely in main(). You must add statements to perform additional calculations, and extend the customer’s statement with additional information. You must use several if-statements. Test your program all over again to make sure it works as specified. For example:

Total Charges for 50 Package A hours: $89.95
A Package B Customer would have saved $46.0
A Package C Customer would have saved $70.0

I have been working on this for several hours and I broke down. I know the area where I am working at *I am flagging the code!* is off/wrong
because I need several IF's, but where??? I don't understand this at all. Would I be using IF ELSE here because one of my classmates said yes but it's not specified....?

This is my code and I'm extremely sorry if all of this looks like a major mess lol but please help me out with this last bit of code:

Tony Docherty

Joined: Aug 07, 2007
Posts: 2837
The simple answer is it's hard to do what you want with the way the code is structured. How much of this was given to you by your teacher as a template?

BTW Are you sure you are calculating the customer's total charges correctly?

I agree. Here's the link:
subject: Using several IF-statements to calculate Packages
jQuery in Action, 3rd edition