Question
Points will be deducted for incorrect file name DOWNLOAD the instructions: program 3 order Calculator.pdf Skeleton code template to help get started: orders_prog3.cpp Here is
Points will be deducted for incorrect file name
DOWNLOAD the instructions: program 3 order Calculator.pdf
Skeleton code template to help get started: orders_prog3.cpp
Here is a code example that may also help: jan31.cpp
Input file: PurchaseData.txt
Sample output: program 3 sample output.txt
Location ID changes for program 2 and program 3:
- 500 TAX rate is 4% (.04)
- 531 TAX rate is 6% (.06)
- 561 TAX rate is 6.6% (.066)
- 581 TAX rate is 7% (.07)
- locationID > 600 - TAX rate is 8.25% (.0825)
- is not a valid entry for the locationID (less than 500 is not valid)
here is a skeleton code
*************************************************************/
#include
#include
#include
using namespace std;
/*********************************************************
//Following is the declaration of a order record
**********************************************************/
class orderRecord
{
public:
//default constructor to initialize the class
orderRecord()
{
cellNum = itemNum = "";
quantity = locID = 0;
price = taxRate = orderTax = netCost = totalCost = 0.0;
};
string cellNum;
string itemNum;
int quantity;
double price;
int locID;
double taxRate;
double orderTax;
double netCost;
double totalCost;
};
//Declaration/ Prototypes for your functions will go here
//BE SURE TO ADD COMMENTS TO THE FUNCTION PROTOTYPES AND THE FUNCTION DEFINITIONS
//ADD the full comments to the function prototypes (pre and post conditions, and
descriptions)
//ADD brief descriptions to the function definitions
void GetInput(ifstream&, orderRecord&);
//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
void ProcessData(orderRecord&);
//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
void GetTaxRate(double&, int);
//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
void ScreenOutput(const orderRecord&);
//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
//HERE IS THE main function, a driver to test your program
int main()
{
string name;
cout
cin >> name;
cout
orderRecord customerData;
ifstream in; //declaring an input file stream
in.open("PurchaseData.txt"); //connect to the input file
if (in.fail())
{
cout
}
else
{
while (!in.eof()) //has not reached the end of the file
{
GetInput(in, customerData);
//call ProcessData
//call ScreenOutput
}
}
in.close();
return 0;
}
//Function Implementations will go here
//Description: Describe what the function does
void GetInput(ifstream& in, orderRecord& p_record)
{
in >> p_record.cellNum;
//add more code to read the rest of the fields (itemNum, quantity, price and
locID) into the
//order record, p_record.
}
//Description: Describe what the function does
void ProcessData(orderRecord& p_record)
{
//Call the GetTaxRate function to get the tax rate
//based on the p_record.locID
//calculate the orderTax, netCost, and totalCost
//of the p_record, example: p_record.taxRate
}
//Description: Describe what the function does
void GetTaxRate(double& taxRate, int locID)
{
//use the location ID to set the tax rate
if (locID >= 500 && locID
taxRate = .04;
}
//Description: Describe what the function does
void ScreenOutput(const orderRecord& p_record)
{
//set the number of decimal places for doubles
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2); //use any number her for the number of decimal places
// display the results here
//cout
//add more code to print all the fields in the order record
}
Annotations
Transcribed image textStep 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