Question: In c + + please: Project 5 Online Groceries PART 1 Background You are building a system to allow customers to order groceries. You have
In c please:
Project Online Groceries PART
Background You are building a system to allow customers to order groceries. You have two files with data:
customers.txt
items.txt
The first file holds customer data in a single text line the following:
Kai Antonikov, Prairie Rose Street,Philadelphia,PAkantonikov@shared.com
The data fields are the customer id name, street, city, state, zip, phone, and email. The file items.txt has fields itemid description, and price:
Almonds Ground Blanched,
Requirements
Write a program that does the following:
Read customerstxt Put the customer records into a global vector.
Read itemstxt Put the item records into a vector.
Display a message stating how many customers there are, and how many items there are.
Prompt the user for a customer number. Search for the customer record.
a If the customer is not found, exit the program with an appropriate message.
bYou may assIn c please:
Project Online Groceries PART
Background You are building a system to allow customers to order groceries. You have two files with data:
customers.txt
items.txt
The first file holds customer data in a single text line the following:
Kai Antonikov, Prairie Rose Street,Philadelphia,PAkantonikov@shared.com
The data fields are the customer id name, street, city, state, zip, phone, and email. The file items.txt has fields itemid description, and price:
Almonds Ground Blanched,
Requirements
Write a program that does the following:
Read customerstxt Put the customer records into a global vector.
Read itemstxt Put the item records into a vector.
Display a message stating how many customers there are, and how many items there are.
Prompt the user for a customer number. Search for the customer record.
a If the customer is not found, exit the program with an appropriate message.
bYou may assume that the user always enters a number.
Prompt for the item number to purchase.
a Display the item description and price.
b Keep track a running totals of items bought, and amount spent.
c If the item is not found, display an appropriate message and continue.
dYou may assume that the user always enters a number.
Continue asking for items until the user enters a for the item number.
Display a message with the number of items purchases and the total cost.
a The total cost should be displayed as a typical money number with a $ sign and dollars and cents. For example, if the total is $ display it as $ Not $ This means you will have to use a bit of output stream formatting.
The program calculates only one customers order. Do not repeat the steps Put all your code in a file called groceries.cpp Use this main function:
int main
readcustomerscustomerstxt;
readitemsitemstxt;
onecustomerorder;
The rest of the steps NOTE:
You will have to declare classes and customers and items. Because they are simple data structures, and you WANT all the data to be available, you can just use a struct for each which is the same as a class with all public members.
Design considerations:
What goes into the Customer class or struct
You can see a customer record has: a Customer id which is an integer b Name c Street address d City e State f Zip code: even though it is a number, store it as a string. g Phone number: also a string just keep the dashes h Email address
What goes into an Item?
a Item Id an integer b Description c Price: This has to be a number, and not an integer! Store it as a double.
How do you read in a record and create an object from it See note below on a function called split that we will provide for you.
Implementation Notes
I have provided a file, split.h which contains a split function that returns all fields that were separated by some character as a vector of strings. You can also use this function to separate the itemidquantity pairs using a dash as the split character.
split.h
#ifndef SPLITH
#define SPLITH
#include
#include
#include
inline std::vector splitconst std::string &s char splitchar
std::istringstream isss;
std::string buffer;
std::vector result;
while getlineiss buffer, splitchar
result.pushbackbuffer;
return result;
#endif
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
