Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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 " to your #include statements in your source file. Add "include " to your #include statements in your source file. Format of the input data file (input filename is "purchase_data.txt"): Do not include column titles (cell phone number, item, quantity, price, processing plant) 07 300 47 51 200 70.82 10.14 23.00 50.12 25.25 105.02 32.41 12.12 9.62 112 100 9546321555 9546321555 5612971340 3051234567 7542346622 3054432762 9544321011 8776219988 9042224556 7877176590 5617278899 9546321555 5612971340 3051234567 7542346622 3054432762 9544321011 8776219988 452-XLY 742-673 924-YUT 9L3-111 453-TTT 213-ABC 321-XMZ 444-SSS 290-P23 23Z-00Q 893-42T 008-LL5 452-XLY 742-6Z3 742-624 742-625 742-6Z6 213-ABC 32 9.62 642 0.81 45.80 99.99 10.14 209 66.48 0.77 1.17 105.02 108 67 500 32.41 12.12 9.92 16 9042224556 7877176590 5617278899 8776219988 9042224556 7877176590 321-XMZ 444-SSS 290-P23 23Z-00Q 232-000 23Z-00Q 9.62 87 9.62 9.62 Format of Output: (cell phone number, item, quantity, price, processing plant, tax rate, order tax, net cost, total order cost) Using the information in the data file "purchase_data.txt" should produce the following output. Your output should not contain any titles, but the output must be in the proper order as stated in the assignment. 9546321555 9546321555 5612971340 3051234567 7542346622 3054432762 9544321011 8776219988 9042224556 7877176590 452-XLY 742-623 924-YUT 913-111 453-TTT 213-ABC 321-XMZ 444-SSS 290-P23 232-00Q 893-427 008-LL5 5617278899 2 300 8 4 7 92 15 112 100 297 32 642 642 90 42 14 13 209 108 67 500 43 16 82 70.82 503 11 15.58 141.64 10.14 47 6 182.52 3042 23 5 1 7 12.88 184 50.12 2008 188.45 2355.64 25.25 110 7 162.61 2323 105.02 8 126.02 1575.3 32.41 7 254.09 3629.92 12.12 86 7 84.84 1212 9.62 500 9 257.14 2857.14 9.62 201 9 27.71 307.84 0.81 0.81 72 7 36.4 520.02 45.8 18 6 247.32 4122 99.99 503 11 461.95 4199.58 10.14 47 6 8 .52 141.96 66.48 6 51.85 864.24 0.77 6 9.66 160.93 1.17 6 7.58 126.36 105.02 8 562.91 7036.34 32.41 9 7 1134.35 16205 12.12 8 7 36.48 521.16 9.92 5 9 14.28 158.72 9.622 9 71 788.84 9.62 9 75.32 836.94 9.62 2 9 385.28 4280.9 9546321555 5612971340 3051234567 7542346622 3054432762 9544321011 8776219988 9042224556 7877176590 5617278899 8776219988 9042224556 7877176590 157.22 3224.52 196.88 2544.09 2485.61 1701.32 3884.01 1296.84 3114.28 335.55 556.42 4369.32 4661.53 150.48 916.09 170.59 133.94 7599.25 17339.35 557.64 173 859.84 912.26 4666.18 452-XLY 742-673 742-624 742-6Z5 742-6Z6 213-ABC 321-XMZ 444-SSS 290.223 23Z-00Q 23Z-00Q 222000 445

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

Does mind reading help or hinder communication?

Answered: 1 week ago