You are going to create a shopping cart using C++ program. First, the program wi
ID: 3720336 • Letter: Y
Question
You are going to create a shopping cart using C++ program. First, the program will ask user’s information (name, address, phone number). Then, display the items menu: 1. Orange $1.00 each 2. Banana $0.40 each 3. Tomato $3.00 each 4. Grape $2.50 each 5. Pear $1.50 each 6. Lemon $0.50 each The program will let the user purchase different item with different quantities each time using loops (you can use any loop). Then, the program calculates the sub-total of each item (subtotal before tax, tax, and sub-total after tax), assume tax is 8.25%. At the end, print a receipt include user’s information, purchase items and sub-totals, and finally, the total price before tax, total tax, and total price after tax.
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
int main ()
{
char Apples = 1$;
char Bananas = 0.40$;
char Oranges = 3$;
char Pears = 0.25$;
char checkout;
char choice;
int total;
int a;
int b;
int c;
int d;
cout << " What would you like to Purchase " << endl;
cout << " 1. [A]pples 1/lb " << endl;
cout << " 2. [B]ananas 0.4/lb " << endl;
cout << " 3. [O]ranges 3/lb " << endl;
cout << " 4. [P]ears 2.5/lb " << endl;
cin>>choice;
if ( choice=='A')
{
cout << " How many LBS would you like to buy? " << endl;
cin >> a;
total= Apples*a;
}
else if (choice =='B')
{
cout << " How many LBS would you like to buy? " << endl;
cin>>b;
total = Bananas*b;
}
else if (choice == 'O')
{
cout << " How many LBS would you like to buy? " << endl;
cin>>c;
total = Oranges*c;
}
else if (choice=='P')
{
cout << " How many LBS would you like to buy? " << endl;
cin>>d;
total = Pears*d;
}
else if (choice=='X')
{
cout << " Would you like to check out? " << endl;
cin>>checkout;
total= A+B+O+P;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.