Not sure how to do this...

Discussion in 'C' started by Naitryn, Feb 5, 2011.

  1. Naitryn

    Naitryn New Member

    Joined:
    Feb 5, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    I've done some C++ programming work but never one like this so I'm a little unsure of what to do. Here's the problem:

    Marcy's Department store is having a BoGoHo. The store manager wants a program that allows the salesclerk to enter the prices of two items. The program should both calculate and display the total amount the customer owes. The half off should always be taken on the item having the lowest price.


    I don't exactly know how to get it to calculate and take the half price off the lesser item. How exactly am I supposed to do this?
     
  2. Umairajmal

    Umairajmal New Member

    Joined:
    Dec 12, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Hazro,Pakistan
    Home Page:
    http://www.facebook.com/m.umairajmal
    Post your code then we can help.
     
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    How would you do it on paper? That's always a good way to start figuring out how to do it. Take a few examples and work them out, and after you've done a few you should start getting the hang of it and be able to determine a step by step approach. Let's say the two items are $100 and $50, so the price is $100+half of $50 which is $125. Or maybe the items are $10 and $20, in which case the cost is $20+half of $10 which is $25. What is the cost of two items $50 and $60?

    Don't be afraid to create new variables. If the items are in item1 and item2, you might want to create intermediate variables costL and costH.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice