Create a C++ Program that will identify the Discount Rate of a shopper based on issued loyalty card, take the following conditions:
Loyalty Card TypeDiscount (%)(1) Frequent Buyer10%(2) One Time Buyer0%(3) Senior Citizen15%
#include <iostream>
using namespace std;
int main()
{
const int FREQUENT_BUYER = 1;
const int ONE_TIME_BUYER = 2;
const int SENIOR_CITIZEN = 3;
const int FREQUENT_DISCOUNT = 10;
const int ONE_TIME_DISCOUNT = 0;
const int SENIOR_DISCOUNT = 15;
cout << "Card types:" << std::endl;
cout << FREQUENT_BUYER << ". Frequent Buyer" << std::endl;
cout << ONE_TIME_BUYER << ". One Time Buyer" << std::endl;
cout << SENIOR_CITIZEN << ". Senior Citizen" << std::endl;
std::cout << "Enter card type(number): ";
int cardType = 0;
std::cin >> cardType;
switch (cardType) {
case FREQUENT_BUYER:
std::cout << "Discount: " << FREQUENT_DISCOUNT << std::endl;
break;
case ONE_TIME_BUYER:
std::cout << "Discount: " << ONE_TIME_DISCOUNT << std::endl;
break;
case SENIOR_CITIZEN:
std::cout << "Discount: " << SENIOR_DISCOUNT << std::endl;
break;
default:
std::cout << "Incorrect card type" << std::endl;
}
return 0;
}
Comments
Leave a comment