Question

Assignment: Write a program in C++ that allows a customer to go on-line shopping. This is...

Assignment: Write a program in C++ that allows a customer to go on-line shopping. This is a start-up venture and the stock of our on-line company is currently limited to the following items:

A gift card to Home Depot, $50.00

A bottle of cologne (The One by Dolce Gabbana), $24.00

3. Akeychainwithabathtubornament,$14.00 4. Acard,$4.00

Although all items are in stock, the customer should only be made aware of the items that he or she can afford. In addition, demand for our services has been so strong that we can only allow each customer to purchase one item. Each available item has a specific int purchase code associated with it. To purchase the desired item, the customer has to enter the specified code. Please be aware that there are many customers who just want to waste our precious computer time and will try to go shopping without any money, we cannot allow this.

The program should work as follows:

 Prompt the customer to enter his or her first name and the amount of money they have to spend.

 If they have no money or worse they are in debt and enter a negative amount, just tell them that they need to earn some money first and do not display any choices.

 If they have money to spend, the program should determine which items, if any, they can afford to purchase.

 Each item they can afford should be displayed along with the unique single digit purchase code required to select that item.

 Assuming a purchase can be made (i.e. the customer can afford at least one item), prompt the user to enter the purchase code of the item they wish to

purchase. You can assume that the customer will only enter a purchase code

from the displayed list of options.

 Once the customer has indicated his or her choice, the program should ask the customer if they would like an on-line receipt. The program should then prompt them for their preferred e-mail address or not.

 As a final courtesy, the program should inform the customer how much cash they still have available to spend, just in case they choose to go shopping again.

Challenge:

Write a function displayItems that display the list of choices they can afford using a correct numerical order. Think what argument you will need to pass to it. Example: '

AgiftcardtoHomeDepot,$50.00

Abottleofcologne,$24.00

Akeychainwithabathtubornament,$14.00

Acard$4.00

or

3. A key chain with a bathtub ornament, $14.00 4. A card $4.00

getName, returns the user name.

displayItems, displays the items that the user can afford

canAfford, returns true if the user can afford a specific item, false otherwise.

This function should be called from function displayItems.

getChoice, returns the user choice (1-4). This function uses the return value of

function canAfford to determine if the user can afford the item they selected.

shopMore, returns true if the user wishes to continue shopping, false otherwise.

Useconstantstorepresentthepricesofthedifferentitems.

Be careful of customer's who try and pull a fast one and enter a purchase code of

an item that was not in their list of choices.

Allow the customer the option of continuing to shop if they still have money

available after making a purchase. Note that this involves implementing a loop.

10.You can write more helper functions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<fstream>
#include <string>

using namespace std;


class Order
{
private:
string customer;
string country ;
string productList[];
int numProducts ;

public:
void createOrder(Customer);
void add(product);
void search(string);
void delete(string);
void display();
};


class Customer
{
private:
string name;
string address;

public:
void createCust(string, string);
void customer(string, string);
void getName();
};

class Product
{
private:
string name;
string model;
float price;

public:
void readRecord(ifstream&);
void createProduct(string, string, float);
void getPrice();
void displayDetails();
void getName();

};

void displayDetails(product p)
{
cout<<"Name:"<<p.name<<endl;
cout<<p.model<<endl;
cout<<"Price:"<<p.price<<endl;

}



class Web_shop
{
private:
string customer;
string products[];
int invoiceNumber;
string order;

public:
void Web_shop();
void readProducts();
void login();
void runShop();
void generateInvoice();
};




int main()
{
int count=0;
product prods[10];
ifstream infile;

infile.open("products.dat");

if(infile.fail()) cout<<"File not found";
else {
// File loopfile.peek()!=EOF) {
infile> 0.5 mark
while(in>prods[count].name>>prods[count].model>>prods[count].price;
count++;
}
}
infile.close();
for(int i=0;i<count;i++)
displayProductDetails(prods[i]);



system("pause");
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Assignment: Write a program in C++ that allows a customer to go on-line shopping. This is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Q1 (2 pts) Shopping list Write a program that prompts a user for items on their...

    Q1 (2 pts) Shopping list Write a program that prompts a user for items on their shopping list and keeps prompting the user until they enter "Done" (make sure your program can stop even if the user enters "Done" with different cases, like "done"), then prints out the items in the list, line by line, and prints the total number of items on the shopping list. Output (after collecting items in the while loop) should look something like this: Apple...

  • 11.12 LAB*: Program: Online shopping cart (continued) This program extends the earlier "Online shopping cart" pr...

    11.12 LAB*: Program: Online shopping cart (continued)This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).(1) Extend the ItemToPurchase class to contain a new attribute. (2 pts)item_description (string) - Set to "none" in default constructorImplement the following method for the ItemToPurchase class.print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter.Ex. of print_item_description() output:Bottled Water: Deer Park, 12 oz.(2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs...

  • Shopping Cart You are to write a program that reads the name of the item, the quantity of each it...

    C++ language Shopping Cart You are to write a program that reads the name of the item, the quantity of each item, and the cost per item from a file. The program will then print out the item and how much is owed for each item. After everything is read in, it will print out the total cost of the cart. Your program should have the following functions main - This function asks the user to enter a filename and...

  • Looking for code in MATLAB: A store owner asks you to write a program for use...

    Looking for code in MATLAB: A store owner asks you to write a program for use in the checkout process. The program should: Prompt the user to enter the cost of the first item Continue to prompt for additional items, until the user enters 0 Display the total. Prompt for the dollar amount the customer submits as payment. Display the change due.

  • 7.11 LAB: Online shopping cart - Part 2 This program extends the earlier "Online shopping cart" program. (Consid...

    7.11 LAB: Online shopping cart - Part 2 This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase namedtuple to contain a new attribute. (2 pts) item_description (string) - Set to "none" in the construct_item() function Implement the following function with an ItemToPurchase as a parameter. print_item_description() - Prints item_name and item_description attribute for an ItemToPurchase namedtuple. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz....

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • 4.18 Ch 7 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping...

    4.18 Ch 7 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (solution from previous lab assignment is provided in Canvas). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by the quantity, price, and subtotal PrintItemDescription() -...

  • Please use C Programming language (Not C++) 7.6 LAB*: Warm up: Online shopping cart (Part 1)...

    Please use C Programming language (Not C++) 7.6 LAB*: Warm up: Online shopping cart (Part 1) (1) Create three files to submit: • Item ToPurchase.h - Struct definition and related function declarations • Item ToPurchase.c-Related function definitions • main.c-main function Build the ItemToPurchase struct with the following specifications: • Data members (3 pts) • char itemName • int itemPrice • int itemQuantity • Related functions • MakeltemBlank0 (2 pts) Has a pointer to an item To Purchase parameter. Sets item's...

  • In C++ Programming Write a program in to help a local restaurant automate its breakfast

    Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:Show the customer the different breakfast items offered by the restaurant.Allow the customer to select more than one item from the menu.Calculate and print the bill.Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item):Use an array menuList of type menuItemType, as defined in Programming Exercise 3. Your program must contain at least the...

  • IN C# Write a program to help a local restaurant automate its lunch billing system. The...

    IN C# Write a program to help a local restaurant automate its lunch billing system. The program should do the following: Show the customer the different lunch items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following lunch items (the price of each item is shown to the right of the item): Ham and Cheese Sandwich $5.00 Tuna Sandwich $6.00 Soup...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT