In: Computer Science
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
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.