Question

In: Computer Science

make a C++ program to calculate discount for a customer. If customer code equals 1 discount...

make a C++ program to calculate discount for a customer.

If customer code equals 1 discount = 5%

Any other code discount = 2%

Display the discount

Solutions

Expert Solution

C++ code:

#include <iostream>     // Including the basic inputs and output services
using namespace std;    // Declaring the standard namespace

int main()      // Main function declaration
{
    int n;      // Integer variable declaration

    cout << "Enter the customer code: ";    // Print command
    cin >> n;           // Reading the user input

    if (n == 1)         // Condition checking
        cout << "The discount for this customer is 5 percent.";      // Printing the discount
    else                // When the customer code is not 1
        cout << "The discount for this customer is 2 percent.";      // Printing the discount

    return 0;       // Return value
}

Output:

Enter the customer code: 1

The discount for this customer is 5 percent

Screenshot (online c++ compiler has been used to compile and run the code):

Please comment in case of any doubt.
Please upvote if this helps.


Related Solutions

make a C++ program to calculate total water bill for a customer. The water company charges...
make a C++ program to calculate total water bill for a customer. The water company charges $250.00 for <=1000 gallons of water. Over 1000 gallons the company charges .99 / gallons The program displays Gallons of water used = xx Exatra payment= xx Total payment = xx
---------------------------------------------------------------------------------------------------------------- C++ //code a program for the following the given Instruction. Geometry Calculator 1. Calculate the...
---------------------------------------------------------------------------------------------------------------- C++ //code a program for the following the given Instruction. Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use 3.14159 for pi. #03   If the user enters 2, the program should ask for the length and width of...
C++ code Output Formatting. Design and implement a complete C++ program that reads a customer record...
C++ code Output Formatting. Design and implement a complete C++ program that reads a customer record from the user such as the record has 4 fields (pieces of information) as shown below: Account Number (integer) Customer full name (string) Customer email (string) Account Balance (double) The program is expected to print the record in the format shown below: Account Number :  0000000 Name                     :  full name Email                      :  customer email Balance                  :  000000.00$ For example, if the user enters the following record 1201077 Jonathan I. Maletic jmaletic@ksu.edu...
Design and implement a C++ program with functions to calculate the pre-tax charge: If the customer...
Design and implement a C++ program with functions to calculate the pre-tax charge: If the customer subscribes to a phone plan called Plan200, then he is charged $5 for the first 200 minutes. For each additional minutes, the customer will be charged $0.10. If the customer subscribes to a phone plan called Max20, then he is charged $0.05 for each minute up to $20. (I.e., the customer never needs to pay more than $20.) If the customer is not subscribed...
Using C++ Write a program to calculate the amount a customer should pay in a checkout...
Using C++ Write a program to calculate the amount a customer should pay in a checkout counter for the purchases in a bagel shop. The products sold are bagels, cream cheese, and coffee. Use the pseudo code discussed in the class to write the program. Make reasonable assumptions about the prices of bagel, cream cheese, and coffee. Declare prices of bagel, cream cheese, and coffee as constants.
Using C++ write a program to calculate the amount a customer should pay in a self...
Using C++ write a program to calculate the amount a customer should pay in a self checkout counter for his purchases in a bagel shop. The products sold are everything bagels, garlic bagels, blueberry bagels, cream cheese, and coffee. Using "doWhile loops" write the program to display the menu of the Bagel shop. Make the user buy multiple items of different choices. Finally display the total amount for the purchases. Below is my current code to work with. Please add...
Please make a C program named: rotate.c This code will contain a single function (and the...
Please make a C program named: rotate.c This code will contain a single function (and the include directive to your header file) to perform the rotation operation using the two integer operands passed to this function. The first integer operand is the number to be rotated. The second integer operand is the number of bit positions that the first operand must be rotated by. EXAMPLE: Enter a 32-bit number (>= 1 and <= 4294967295, inclusively): 1 Enter the number of...
Overview For this program, add code to program 2 that will (potentially) allow for a discount...
Overview For this program, add code to program 2 that will (potentially) allow for a discount to be applied to the cost of the tickets to the movie theater. Basic Program Logic The program should start the same as program 2 by asking the user for the number of tickets to purchase for adult and children. The program should then ask the user if they have a discount coupon. This is a string value. A value of "Y" indicates the...
I. Design the C++ code for a program which will use the Pythagorean Theroem to calculate...
I. Design the C++ code for a program which will use the Pythagorean Theroem to calculate and display the length of a right triangle hypotenuse,c, given the lengths of its adjacent sides: a and b.. (hint: a^2 + b^2 = c^2) II. Design the C++ code for a program which will calculate and display the roots of a quadratic equation of the form ax^2 + bx + c = 0, given its coefficients, a, b, and c.
PROGRAM INSTRUCTIONS: 1. Code an application that asks the customer for a log-in and password. 2....
PROGRAM INSTRUCTIONS: 1. Code an application that asks the customer for a log-in and password. 2. The real log-in is "Buffet2011" and the real password is "Rank1Bill2008". 3. Allow the customer two (2) attempts to type either. a. Each time the customer enters an invalid log-in or password issue an error message. b. If the customer fails all two (2) log-in attempts, issue another error message and exit the program. c. If the log-in is successful, the customer can calculate...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT