Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Really Stuck on how to Start this program

    Okay, I know I should be posting some code here and showing where I've started and such, but I'm pretty lost as to how to start this program. Here's the problem:

    2. Making Change:

    This application, named ChangeMaker, will take as input a product price and an amount paid,
    both floating-point numbers representing euro and cent amounts. The application computes and prints the amount of change due the user, and also expresses the change amount in number of 2-euros, 1-euro, 20-cent, 10-cent, 5-cent, 2-cent, and1-cent coins.

    (Assume no change is given in bills, only in coins.)

    For example:
    Enter product price: 2.32
    Enter amount paid: 5.00
    Your change is 2.68 euros
    1 x 2 euro
    3 x 20-cent
    1 x 5 cent
    1 x 2 cent
    1 x 1 cent

    You can assume that the amount paid is greater than the product price, and that both inputs are
    "euro and cent" amounts: positive numbers with at most two decimal places.3

    Now, I know how to print the line asking for product price and enter amount paid, but I cannot figure out how to set up the rest of the code when switching from american USD dollars/coins to euros. I looked up the conversions and they are just intimidating as all get out when trying to take the equivalency of euros to each dollar thats entered and then taking the rest of the USD remainders and represent that in USD coinage. >.< Help is much appreciated thank you.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I'm not going to read you're whole post, lol.
    Sounds like an assignment so I can't give you code, only ideas (our rules say we can't really help you on assignments).
    Logic:
    - Calculate change (easy subtraction)
    - Foreach type of change, modulus division against remaining result calculate integer result.
    - Subtract integer result of modulus from remaining change.
    - Next type

    Drill it down, with or without a loop.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Awesome thank you so much for the hints everyone to start this program. I'm going to see what I can do without banging my head to much on this stupid monitor screen >.< bleh!! I'll let you know with what I can come up with.

  • #4
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I finally figured it out with lots of help from other students in the class. It was much easier than it appeared to be. Thanks for the hints much appreciated ^^

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    NP Mate, glad you got it working.
    Out of curiosity, what route did you take to do this (there are a number of ways to do this now that I think about it)?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •