• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calculating savings

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if I am on the right track, but I added some to it. My program does not do what it is supposed to, but I think I am heading into the right direction?


 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic