I'm working on a program that is suppose to display the amount of reward points a customer has accumulated based on their membership type and amount of monthly purchases. There are three membership types: Standard, Plus, and Premium. The rewards accumulated are based on how much the member has spent.
Example:
-Standard members receive rewards equaling 5% of monthly purchases if they've spent less than $75, 7.5% if they've spend more than $75, but less than $149.99, and 10% for any amount above $149.99
-Plus members receive 6% of monthly purchases if they've spent less than $150, and 13% for any amount above $149.99
-Premium members receive 4% of monthly purchases if they've spent less than $200 and 15% for any amount above $199.99
My program will only display 0 as points accumulated. I have to use voids. Please Help.
Yesterday when I wrote the last message I was interrupted and lost my thought. That is why I ended up thinking that all three functions could be done in one. When I started working on the program I realized different.
The function call only needs to be: rewardPoints = RewardPointsPM(monthlyPurchase); and in the function definition all you need is: double RewardPointsST(constdouble total). "total" does not need to be passed by reference because you should not be changing this variable in this function. And the type of variable is not a porblem to pass by value.
Variables like "STRATE1" do not need passed to the functions because they are global variables and any code in the file has access to them.
Inside the three "rewardPoints" functions since all the if/else if statements are one line statements the {}s are not needed. As an example you could write the if/else if statements as return rewardPoints = total * STRATE1;. It works the same with or without the return. The single else statement should not be here. By the time you get to these functions the variable being passed should be verified and correct to start with.
If I missed anything or you do not understand let me know.