Answer to Question #245693 in C++ for potato

Question #245693

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%



1
Expert's answer
2021-10-02T07:24:23-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS