In: Computer Science
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.
Program:
#include <iostream>
using namespace std;
int main() {
int n,numberOfbagels,numberOfcream_cheeses,numberOfcoffees;
double bagels,cream_cheese,coffees,pay; // variable declaration
bagels =10; // consider bagel price as 10
cream_cheese = 20; // consider cream_cheese price as 20
coffees = 30; // consider coffee price as 30
cout <<"Enter number of bagels purchased: ";
cin>>numberOfbagels; // Accept number of bagels purchased
cout <<"Enter number of cream cheese purchased: ";
cin>>numberOfcream_cheeses; // Accept number of cream_cheeses purchased
cout <<"Enter number of coffes purchased: ";
cin>>numberOfcoffees; // Accept number of coffees purchased
pay = numberOfbagels*bagels + numberOfcream_cheeses *cream_cheese + numberOfcoffees * coffees; // Calculate the amount need to pay
cout<<"The amount customer should pay in a checkout counter for the purchases in a bagel shop: "<<pay<<endl; // print the amount need to pay
}
Output: