Question
i need help making this program
the skeleton of the code is below:
//Include the following

#include <iostream>
#include <string>
#include <fstream>  //you must include this library if you wish to do file i/o
using namespace std;

/*********************************************************
//Following is the declaration of a order record
**********************************************************/
class order_record
{
public:
        string cell_number;
        string item_number;
        double quantity;
        double price;
        int processing_plant;
        double tax_rate;
        double order_tax;
        double net_cost;
        double total_cost;
};


//Prototypes for your functions: input, output, and process will go here

void input(ifstream &, order_record &);
void output(const order_record &);
void process(order_record &);

//Function Implementations will go here

///*************************************************************************************
//Name:  input
//Precondition: State what is true before the function is called.
// Example: the varialbes (formal parameters) have not been initialized
//Postcondition: State what is true after the function has executed.
// Example: the varaibles (formal parameters) have been initialized
//Description:  
// Example:Get input (values of cell_number, item_number, quantity, price, processing_plant ) 
//from data file order record (p_record).

//PURPOSE: SHOW ME THAT YOU KNOW HOW TO READ INPUT AND USE INPUT (CALL BY VALUE) & OUTPUT (CALL BY VALUE) PARAMETERS

//*************************************************************************************

void input(ifstream & in, order_record & p_record) // example using the call by reference mechanism in C++ -- call record is passed by reference --note & operator
{
        in >> p_record.cell_number;
        //add more code to read the rest of the fields (item_number, quantity, price and processing_plant) into the 
        //order record, p_record.
}

///*************************************************************************************
//Name:  output
//Precondition: State what is true before the function is called.
//Postcondition: State what is true after the function has executed.
//Description:  Describe what the function does (purpose).
//*************************************************************************************

void output(const order_record & p_record)
{
        //Use thee following statement to help you format you our output. These statements are called the magic formula.
        cout.setf(ios::showpoint);
        cout.precision(2);
        cout.setf(ios::fixed);
        /********************************************/


        //cout << p_record.cell_number << "\t";
        //add more code to print all the fields in the order record
        

}

///*************************************************************************************
//Name:  process
//Precondition: The state what is true before the function is called.
//Postcondition: State what is true after the function has executed.
//Description:  Describe what the function does (purpose).
//*************************************************************************************

//Note: there is one 1 input/output parameter
void process(order_record & p_record)
{

        //put your code here to process/calculate the tax_rate, order_tax, net_cost, and total_cost
        //the p_record

}

//Here is your driver to test the program
int main()
{

        order_record customer_record;

        ifstream in;    //declaring an input file stream
        in.open("purchase_data.txt");

        if (in.fail())
        {
                cout << "Input file did not open correctly" << endl;
        }
        else
        {
                while (!in.eof())
                {
                        input(in, customer_record);
                        //process(customer_record);
                        //output(customer_record);
                }
        }

        in.close();

        return 0;
}


In this assignment you will mplement a program called amazem orderscpp to process customer purchase orders (orders) on Amazon
>500 then nax rate-11% b. The lax on an order (order ax) is calculatod by the following formula: order ax-(qwantnyx(rice) x a
Outpat Format for the Fanction owrur Coasider the following sample output table when designing and implementing te function
(cell phone number, item, quantity, price, processing plant, tax rate, onder tax, net cost, total order cost) Using the infor
In this assignment you will mplement a program called amazem orderscpp to process customer purchase orders (orders) on Amazon The purchase orders will be stored in order records. Each order record contains nine ficlds, which are as tollows: 1) a ten digit customer cell phone number (string, no dashes), 2) the iem number (string). 3) the number of tems (quantity) 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 has been reached. Following are the descriptions of the functionality of each function: will call (invoke) each function until the end of the data file 1. The void function "inpu" will have two parameters an ingut file stream called "in", and a customer purchase order record called "order record The function will read the cell number (cusiomer 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 a order record (Amaron purchase order) from the data file 2· The function "process" will calculate the order tax rate ir-rare), net cost of an order (net cost), the tax on an order (onder ax and the total cost of an order (total cost) using the quantiry, cost of an item (price, and pracessing plant idennfication number (processing plan) for a paurnchase order record (order record), Please consider the following a. The fax rate on an arder (ax rate) is simply based on the where the onder was processed (0cssing plant-S0 then 2,500 then Mr. rare-11%) b. The tax on an onder (order ax is calculated by the following formula orderax-(uantiy)x(vice) x ax rate)0 c. The net cost ef an erder (net cost), which does not include tax, is calculated by the following formula net cost (wantyx price d. The total cost of an order ( rounded to the nearest hundredth is calculated by the following formula: total cost net cost 4 arder fax. All tax and cest calculations should be rounded to the nearest 3. The function "output" will print every field of an order record The fields should be printed in the following order I) cellphone number, 2) item number, 3) quantty, 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 Sream and Format of Outpet for the function outpet" for more information. See the section "Format of Iapet Data File (input filename is "parchase data.tst") 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 a good 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) to start with the skeleton program I
>500 then nax rate-11% b. The lax on an order (order ax) is calculatod by the following formula: order ax-(qwantnyx(rice) x ax rate Iwy c. The net cost of an ander (net cost), which does not include tax, is calculated by the folowing formula ner cost-(qwantyix price d. The total cost ofan order f reanded to the meares hundredth) is calculated by the following formula total cost net cest + ander All tas and cest calculations should be rounded to the nearest . The function "output" will print every field of an onder recond The fields should be printed in the fllowu写order I 》 cellphone number, 2) item number, 3) quantity,4) price, 5 processing plant, 6) tax rate, 7) oeder tax, 8) net cost, and 9) total cost of order. See sections below calledIapat Sream and Format of Outpat for the function ostpet" for more information. See the section -Format of laput Data File input flename is "parchase dat 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 a good to start with the skeleton program I provide. Remember to follow all style rules and to include all necessary documentation (consistent, indentation, peoper vaniable names, prelpost condition, program header, fiunction headerms, and so forth Finally, your input data file (purchase daaoot) should be in the same directory as your program source file (amazon orderscpp. Output Format for the Fanction otpr Coasider the following sample output table when designing and implementing the function "Owtpwr 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) 546121555 452-KY 546321555s 42623 00 1014 Input Stream: In the assignment you will declare one ifstream to bind your input to the file "purehase data. Whenever a program performs file io you must include the "Istream"libeary Add the following statoments to your program For source file, "amazon orders. Add .#include . to your # include shitements in your source file.
Outpat Format for the Fanction "owrur Coasider the following sample output table when designing and implementing te function "Outpur" (The output is in the following order cell phone number, item number, quantay, price, process plant, tax rate, order tax, net cost, total order cost 2 70.82 0B 11 15.58 4164 157.22 9546121555 742-63 1 100 10.14 182.5 0200 3224.5 Input Stream: In the assignment you will declare one ifstream to bind your input to the Sle "purchase data.tr Whenever a program performs file Vo you must include the "Estream" lhrary. Add the following statcments to your program For source file, "amazon nders.cpp" Add Minclude cEstrea to yourinclude statements in your source file Add "include to your # include statements in your source file Format of the inpet data filetinpet Rename "prcase detser (cell phone number, item, quantity, price, processing plant De n include celeme titles 2 7082 S 300 10 34 8 200 $1 051234567 92 25 25 15 10503111 20 290-P23 297 9.6 2962 201 877176590 99 澼 561297130 108 117 02 111 82 96 87 96 21 230 445 Format of Output (cell phone number, nem, quaetty, price, processing plan a aleorder tax, net cost, toeal onder cost Using the information in the data file purchase data td should produce the following ouput. Your outpu should not centain any tieles, but the output must be in the proper order as stated in the assignment 546321555 52-LY 2 7082 S03 1.581414 5722 300 10144 8 2300 5 5612971340 24-YUT 0%1234567 9313T 54246622 -TIT 7 12.88 184.00 19688 47 501 200 92 2525 11O LRA4 235S 548.09 7162.6 232300 2485 6 213 ABC B 126.02 1575.30 1701 32 7254.9 36299 840 7 84. 121200 129684 44121011 321-MZ 100 12.12 257.14 2857.14 311428
(cell phone number, item, quantity, price, processing plant, tax rate, onder tax, net cost, total order cost) Using the information in the data file "purchase data txf" 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
0 0
Add a comment Improve this question Transcribed image text
Answer #1


//Include the following

#include <iostream>
#include <string>
#include <fstream> //you must include this library if you wish to do file i/o
using namespace std;

/*********************************************************
//Following is the declaration of a order record
**********************************************************/
class order_record
{
public:
   string cell_number;
   string item_number;
   double quantity;
   double price;
   int processing_plant;
   double tax_rate;
   double order_tax;
   double net_cost;
   double total_cost;
};


//Prototypes for your functions: input, output, and process will go here

void input(ifstream &, order_record &);
void output(const order_record &);
void process(order_record &);

//Function Implementations will go here

///*************************************************************************************
//Name: input
//Precondition: State what is true before the function is called.
// Example: the varialbes (formal parameters) have not been initialized
//Postcondition: State what is true after the function has executed.
// Example: the varaibles (formal parameters) have been initialized
//Description:
// Example:Get input (values of cell_number, item_number, quantity, price, processing_plant )
//from data file order record (p_record).

//PURPOSE: SHOW ME THAT YOU KNOW HOW TO READ INPUT AND USE INPUT (CALL BY VALUE) & OUTPUT (CALL BY VALUE) PARAMETERS

//*************************************************************************************

void input(ifstream & in, order_record & p_record) // example using the call by reference mechanism in C++ -- call record is passed by reference --note & operator
{
   in >> p_record.cell_number;
   in >> p_record.item_number;
   in >> p_record.quantity;
   in >> p_record.price;
   in >> p_record.processing_plant;
   //add more code to read the rest of the fields (item_number, quantity, price and processing_plant) into the
   //order record, p_record.
}

///*************************************************************************************
//Name: output
//Precondition: State what is true before the function is called.
//Postcondition: State what is true after the function has executed.
//Description: Describe what the function does (purpose).
//*************************************************************************************

void output(const order_record & p_record)
{
   //Use thee following statement to help you format you our output. These statements are called the magic formula.
   cout.setf(ios::showpoint);
   cout.precision(2);
   cout.setf(ios::fixed);
   /********************************************/

   cout << p_record.cell_number << "\t";
   cout << p_record.item_number << "\t";
   cout << p_record.quantity << "\t";
   cout << p_record.price << "\t";
   cout << p_record.processing_plant << "\t";
   cout << p_record.tax_rate << "\t";
   cout << p_record.order_tax << "\t";
   cout << p_record.net_cost << "\t";
   cout << p_record.total_cost << endl;
   //add more code to print all the fields in the order record
  

}

///*************************************************************************************
//Name: process
//Precondition: The state what is true before the function is called.
//Postcondition: State what is true after the function has executed.
//Description: Describe what the function does (purpose).
//*************************************************************************************

//Note: there is one 1 input/output parameter
void process(order_record & p_record)
{

   //put your code here to process/calculate the tax_rate, order_tax, net_cost, and total_cost
   //the p_record
   if (0<=p_record.processing_plant && p_record.processing_plant <=50){p_record.tax_rate = .06;}
   else if (50<p_record.processing_plant && p_record.processing_plant <=110){p_record.tax_rate = .07;}
   else if (110<p_record.processing_plant && p_record.processing_plant <=200){p_record.tax_rate = .08;}
   else if (200<p_record.processing_plant && p_record.processing_plant <=500){p_record.tax_rate = .09;}
   else p_record.tax_rate = .11;
   p_record.order_tax = p_record.quantity * p_record.price * p_record.tax_rate;
   p_record.net_cost = p_record.quantity * p_record.price;
   p_record.total_cost = p_record.net_cost + p_record.order_tax;
}

//Here is your driver to test the program
int main()
{

   order_record customer_record;

   ifstream in;    //declaring an input file stream
   in.open("purchase_data.txt");

   if (in.fail())
   {
       cout << "Input file did not open correctly" << endl;
   }
   else
   {
       while (!in.eof())
       {
           input(in, customer_record);
           process(customer_record);
           output(customer_record);
       }
   }

   in.close();

   return 0;
}

Add a comment
Know the answer?
Add Answer to:
i need help making this program the skeleton of the code is below: //Include the following #include <iostream> #...
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
  • Write a program **(IN C)** that displays all the phone numbers in a file that match the area code...

    Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...

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

    In C++ Programming Write a program in Restaurant.cpp 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): Name Price Egg (cooked to order)...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • Write a program in C++ that simulates a soft drink machine. The program will need several...

    Write a program in C++ that simulates a soft drink machine. The program will need several classes: DrinkItem, DrinkMachine and Receipt. For each of the classes you must create the constructors and member functions required below. You can, optionally, add additional private member functions that can be used for doing implementation work within the class. DrinkItem class The DrinkItem class will contains the following private data members: name: Drink name (type of drink – read in from a file). Type...

  • NEED HELP BEING SOLVED IN C++! USE ORIGINAL CODE TO ADD TO AS WELL! #include<iostream> using...

    NEED HELP BEING SOLVED IN C++! USE ORIGINAL CODE TO ADD TO AS WELL! #include<iostream> using namespace std; int main(){    for (int i = 0; i < 7; i++) { int x,y; char opr; cin>>x>>y>>opr;    switch(opr) { case '+': cout<<x<<" + "<<y<<" = "<<x+y; break; case '-': cout<<x<<" - "<<y<<" = "<<x-y; break; case '*': cout<<x<<" * "<<y<<" = "<<x*y; break; case '/': if(y == 0) cout<<x<<" / "<<y<<" = "<<"ERROR"; else cout<<x<<" / "<<y<<" = "<<x/y<<"R"<<x%y; break;...

  • Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses:...

    Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required.    Project Requirements Develop a text...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data...

    need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data file – It has: player ID, player first name, middle initial, last name soccer.txt – Player information file – It has: player ID, goals scored, number of penalties, jersey number output file - formatted according to the example provided later in this assignment a) Define a struct to hold the information for a person storing first name, middle initial, and   last name). b) Define...

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

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