Question
My code for previous assignment and now I cant get the correct output file to work when i adjust the code #include #include #include using
My code for previous assignment and now I cant get the correct output file to work when i adjust the code
#include
#include
#include
using namespace std;
struct purchase_order {
string phone_number;
string itemnumber;
double numberofitems;
double cost;
int process_dataing_plant_number;
double tax_rateorder;
double purhase_order_tax;
double net_cost_order;
double total_cost_order;
};
void input_data(ifstream &, purchase_order &);
void output_data(const purchase_order &);
void process_data(purchase_order &);
//call by reference
void input_data(ifstream &in, purchase_order &process_record)
{
in >> process_record.phone_number;
in >> process_record.itemnumber >> process_record.numberofitems >> process_record.cost >>
process_record.process_dataing_plant_number;
}
void output_data(const purchase_order &process_record) {
cout.setf(ios::showpoint);
cout.precision(2);
cout.setf(ios::fixed);
cout
// display record
cout
}
void process_data(purchase_order &process_record) {
if (0
process_record.tax_rateorder = 6;
else if (51
process_record.tax_rateorder = 7;
else if (111
process_record.tax_rateorder = 8;
else if (201
process_record.tax_rateorder = 9;
else if (process_record.process_dataing_plant_number > 500)
process_record.tax_rateorder = 11;
process_record.purhase_order_tax =
process_record.numberofitems * process_record.cost * (process_record.tax_rateorder / 100.0);
process_record.net_cost_order = process_record.numberofitems * process_record.cost;
process_record.total_cost_order = process_record.net_cost_order + process_record.purhase_order_tax;
}
int main() {
purchase_order cus_record;
ifstream in;
in.open("purchase_dataAssignment4.txt");
if (in.fail()) {
cout
}
else {
while (!in.eof()) {
input_data(in, cus_record);
process_data(cus_record);
output_data(cus_record);
}
}
in.close();
return 0;
}
COP3014-Foundations of Computer Science Assignment #5 This assignment is an extension of Programming Assignments 2 and 3. In this assignment you will implement a program called "amazon_porders.cpp" to process customer purchase orders (orders) on Amazon and print the results to a data file called "amazon_inventoryoutputtxt". The purchase orders will be stored in order records. Each order record contains nine fields, which are as follows: 1) a ten digit customer cell phone number (string, no dashes), 2) the item number (string), 3) the number of items (quantity) in the purchase order (integer),4) the cost (price) of one item ( double), 5) processing plant number (integer), 6) the tax rate on the order (double), 7) the net cost of the purchase order (double), 8) the purchase order tax (double) and 9) the total cost of the purchase order (double). Your program will have 3 functions: input, process and output. Your main program will call (invoke) each function until the end of the data file has been reached. Following are the descriptions of the functionality of each function: 1. The void function "input" will have two parameters: an input file stream called "in", and a customer purchase order record called "order_record". The function will read the cell_number (customer cell phone number), item_number item identification number), quantity (number of items in purchase order), price (cost of one item) and processing plant (processing plant identification number), into the order_record (Amazon purchase order) from the data file, "purchase_data.txt". 2. The function "process" will calculate the order tax rate (tax_rate), net cost of an order (net_cost), the tax on an order (order_tax) and the total cost of an order (total_cost) using the quantity, cost of an item (price), and processing plant identification number (processing_plant) for a purchase order record (order_record). Please consider the following: a. The tax rate on an order (tax_rate) is simply based on the processing plant identification number (processing_plant) which is where the order was processed (0500 then tax rate =11%). b. The tax on an order (order_tax) is calculated by the following formula: order_tax = (quantity) x (price) x [(tax_rate) / 100) C. The net cost of an order (net_cost), which does not include tax, is calculated by the following formula: net_cost = ( quantity) x price. d. The total cost of an order (rounded to the nearest hundredth) is calculated by the following formula: total_cost = net_cost + order_tax. All tax and cost calculations should be rounded to the nearest hundredths. 3. The function "output" will print every field of an order record to a data file called "amazon_inventoryoutput.txt". The function output will have two parameters: an output file stream called "out", and a customer purchase order record called "order_record". The fields should be printed in the following order: 1) cell phone number, 2) item_number, 3) quantity, 4) price, 5) processing_plant, 6) tax rate, 7) order tax, 8) net cost, and 9) total cost of order. See sections below called "Input Stream" and "Format of Output for the function output" for more information. See the section "Format of Input Data File (input filename is "purchase_data.txt")". You may implement more functions if you find it necessary. Please start the assignment ASAP, and ask questions to make sure you understand what you must do. It is always good to start with the skeleton program provide. Remember to follow all style rules and to include all necessary documentation (consistent, indentation, proper variable names, pre/post condition, program header, function headers, and so forth.) Submit the file "amazon_porders.cpp" to Canvas before the due date and time. Finally, your input data file (purchase_data.txt) should be in the same directory as your program source file (amazon_porders.cpp). Output Format for the Function "output": Consider the following sample output table when designing and implementing the function "Output". (Note: the output data file is called "amazon_inventoryoutput.txt:. (The output is in the following order: cell phone number, item number, quantity, price, process plant, tax rate, order tax, net cost, total order cost) 9546321555 452-XLY 9546321555 742-623 2 300 70.82 10.14 503 47 11 6 15.58 182.52 141.64 3042.00 157.22 3224.52 Input Stream: In the assignment you will declare one ifstream to bind your input to the file "purchase_data.txt". Whenever a program performs file i/o you must include the "fstream" library. Add the following statements to your program: For source file, "amazon_porders.cpp": Add "#include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started