Help with looping a discount(I think)?

closed account (SGwM92yv)
My problem/What I think I need to do:

My code satisfies the 15% discount with the loyalty card and the 10% discount is over 100. They do not combine either after testing since I used "else if." I am confused as to how to do the additional 1% discount for every extra $25 over 100 dollars in conjunction with the already 10% discount. I assume I have to do a loop? If that is correct, but I am not familiar with loops and I wouldn't know how to set up the additional discount. Thank you for your time!~

P.S: I am in no way asking for anyone to tell me the answer to my assignment! I read the rules on homework. I just gave the assignment instructions and my code for context. I have no previous experience with c++ and the first time I saw it was three weeks ago. I would just appreciate some insight into how to solve this. I am not trying to cheat or anything! I just really need help understanding... :)
Last edited on
Hi,

from line 26 you may do something like this (no loops)

26
27
28
29
30
31
32
33
34
35
 else if (total >= 100)
    {
        int totdisc=0;
    totdisc=(total-100)/25;//this is int so it will only return int and leve the remainder
  
//using float for type casting

        discountPercentage = 0.10+((float)totdisc/100);//this will add the 100th of total disc
    }//i.e. for 1 totaldisc the disc percent will be 1/100=0.01


I'll leave the 25% cap to you

HOPE IT HELPS

Further reading:
http://stackoverflow.com/questions/5456801/c-int-float-casting

http://www.cplusplus.com/doc/tutorial/control/
although this question does not require any loops but you have to read it someday so why not now? :)
closed account (SGwM92yv)
Thank you so much!! Thank you for the comments as well so I could understand your additions.
Last edited on
welcome :)
Topic archived. No new replies allowed.