Function overloading

PLEASE HELP !! Question is a restaurant provides its customers a membership card option that gives them discount on meals. Three membership cards with different discounts are available:
· Silver: 5% of the total bill
· Gold: 10% of the total bill
· Platinum: 15% of the total bill
If it is Thursday, an additional discount between 5% and 10% is given, decided by the manager,
whether you have a membership card or not.
Your task is to write a C++ program that calculates the discount for a bill. Function
CalcDiscount() calculates the discount and should be overloaded. In the first instance the
function receives two parameters, namely the total bill amount and the discount percentage
according to the membership status, and the function returns the calculated discount amount. In
the second instance the function receives the total bill amount, the discount percentage
according to the membership status, and the discount amount applicable for a Thursday, and
returns the calculated discount amount.
Ask the user to enter the total bill amount, as well as the membership status. Also ask the user if
it is Thursday. If it is Thursday, ask the user to enter the special discount for the day. Depending
22
on the user’s answers, call the correct CalcDiscount()function. Display the discount amount
that the client receives on the screen.
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Hi this is my attempt until now, and still working on it but i understand something i am not doing right. Please help.


#include <iostream>
using namespace std;
double CalcDiscount(int total_bill, int discount);
double CalcDiscount(int total_bill, int discount, int specl_discount );



int main()
{
int total_bill, discount, specl_discount;

string day;
cout << "Enter total bill amount of the customer" << endl;
cin >> total_bill;
discount= CalcDiscount( total_bill, discount);
specl_discount = CalcDiscount(total_bill,discount, specl_discount);

cout << endl;
cout << " Total bill amount is "<< total_bill<<endl;
cout << " discount amount is "<< discount<< endl;

cout << discount;
return 0;
}

double CalcDiscount(int total_bill, int discount);
{
char card_name;

cout <<" Enter the first letter of membership card name "<< endl;
cin >> card_name;

switch(card_name)
{
case 's':
case 'S':
discount = total_bill*5/100;
break;
case 'g':
case 'G':
discount = total_bill*10/100;
break;
case 'p':
case 'P':
discount = total_bill*15/100;
break;
default:

}
return discount ;
}

double CalcDiscount(int total_bill, int discount, int specl_discount);
{
char card_name;
string day;
int specl_discount;

cout << " enter the foirst letter of membership card" << endl;
cin >> card_name;
cout << " Enter the day the customer having meal"<< endl;
cin >> day;
if (day == "Thursday")
{
cout<< " Enter special discount of the day"<< endl;
cin >> specl_discount;
}
switch (card_name)
{
case 'S':
case's':
discount= (total_bill*(5/100)*(specl_discount/100));
break;
case 'G':
case 'g':
discount= (total_bill*(10/100)*(specl_discount/100));
break;
case'P':
case 'P';
discount = (total_bill*(15/100)*(specl_discount/100));
break;
default:


}
return discount;
}
1) Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

2) "something i am not doing right" is not a helpful description of your problem. What problem are you seeing? A compilation error? A run-time crash? Something else?

We can't read your mind. You have to actually tell us what the problem is.
Topic archived. No new replies allowed.