posted 2 years ago
I am very new to programming. I have a program written out to show the monthly bill of different service providers. I figured out that part, no problem. I need to calculate savings, if any, between packages A and B, B and C, as well as B and C. I have looked through my book and I can't figure it out for the life of me. I don't know what to do at this point. Any help would be greatly appreciated! I am supposed to use the Scanner class, switch statement, and if statements.
Jack Tabby
Greenhorn
Posts: 2
posted 2 years ago
your first code works fine
Which package did you purchase? Enter A, B, or C: A
How many hours did you use?: 12
Your monthly bill is $13.95
what's your exact query? You need to calculate saving between A and B, B and C, as well as B and C as per you said. so do you want your program to ask for different packages how many hours did you use one by one?
If you can, write what output you want. according to that the program should be written
Which package did you purchase? Enter A, B, or C: A
How many hours did you use?: 12
Your monthly bill is $13.95
what's your exact query? You need to calculate saving between A and B, B and C, as well as B and C as per you said. so do you want your program to ask for different packages how many hours did you use one by one?
If you can, write what output you want. according to that the program should be written
posted 2 years ago
Welcome to the Ranch
I am afraid your question suggests to me that you are guessing. You mustn't guess. Well, you can. If you make 1000000 guesses, make sure they are all different, and there is a good chance one will be correct. Or you can work it out and get it right first time
SB suggests your first code works, but I am afraid that doesn't get you very far. You have not written object‑oriented code. you should have a Package class with a price field. You should instantiate three Package objects and get them to work out the cost of each. You should remove all that code from the main method.
I suggest you need to turn your computer off and work out with pencil and paper how you intend to calculate the charges. I see there is a formula with monthly fee, base hours and additional hours. One of the packages does not seem to have base hours, but you can easily put that in the same formula by using 0 for base hours. Or maybe 0 for charge per additional hour.
I am afraid your question suggests to me that you are guessing. You mustn't guess. Well, you can. If you make 1000000 guesses, make sure they are all different, and there is a good chance one will be correct. Or you can work it out and get it right first time
SB suggests your first code works, but I am afraid that doesn't get you very far. You have not written object‑oriented code. you should have a Package class with a price field. You should instantiate three Package objects and get them to work out the cost of each. You should remove all that code from the main method.
I suggest you need to turn your computer off and work out with pencil and paper how you intend to calculate the charges. I see there is a formula with monthly fee, base hours and additional hours. One of the packages does not seem to have base hours, but you can easily put that in the same formula by using 0 for base hours. Or maybe 0 for charge per additional hour.
Hey cool! They got a blimp! But I have a tiny ad:
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
