Assignment purpose: i/o in C++, control structures (if/ else if/ else), math in C++, data types string, double, and int, formatting output in C++, functions, call by reference, struct declaration, and file input.
Budget: $10 – $30 USD
You will write a program that will calculate the tax (tax) , the net cost (netCost) , and the total cost (totalCost) of a
sports equipment order. Different locations have different tax rates.
The phone number (string), item name (string), item number (string), quantity (integer), unit price (double),
location ID (integer) will be read from an input file called sportsEquipment.txt
The input file has only 5 items.
You will need to update the input file which should have a minimum of 10 items.
You can use the 5 already in the file and add at least 5 more or create your
own 10 items.
Be sure the input file is in the same location as your source code!
Use the information below to determine the tax rate based on the location ID (locID ) , calculate the tax, netCost, and
totalCost for each line in the file and display the results onto the screen in columns using \t(tab), see the sample
output provided.
You can modify the way the information is presented on the screen, you do not
need to follow my sample output, but you must use some columns and all the
information must be printed onto the screen for each order.
o locID is 1– TAX rate is 7.25% (.0725)
o 2 <= locID <=5 – TAX rate is 7% (.07)
o 6 <= locID <= 7– TAX rate is 6.85% (.0685)
o 8 <= locID <= 15 – TAX rate is 6.5% (.065)
o 16 <= locID <= 27 – TAX rate is 6 % (.06)
o 28 <= locD <= 33 – TAX rate is 5.5% (.055)
o 34 <= locD <= 35 – TAX rate is 5% (.05)
o 36 <= locID <= 40 – TAX rate is 4.45% (.0445)
o 41 <= locID <= 45 – TAX rate is 4% (.04)
o locID is 46 – TAX rate is 2.90% (.0290)
o 47 <= locID <= 51 – TAX rate is 0% (.00)
o < 0 – is not a valid entry for the locID
o > 51– is not a valid entry for the locID
• Use a string for the users first name only as you interact with the user
Use the struct below to store the data for each record:
struct equipmentRecord
{
string cellNumber;
string itemName;
string itemNumber;
int quantity;
double price;
int locID;
double taxRate;
double tax;
double netCost;
double totalCost;
};
//BE SURE TO ADD COMMENTS TO THE FUNCTION PROTOTYPES (above main)
//AND TO THE FUNCITON DEFINITIONS (below main)
//USE pre and post conditions with descriptions
//see the sample provided
For program 3 you must use the following functions exactly as described below (same name and same formal
parameter data types in the same order):
void GetDataInput(ifstream&, equipmentRecord&);
void ProcessData(equipmentRecord&);
void GetTaxRate(double&, int);
void DisplayOutput(const equipmentRecord&);
All double output should be presented with 2 decimal places (see sample output)
** The purpose of the assignment is to practice using a struct, file input, and pass by reference parameters
You may add additional functions, but you MAY NOT modify the name or the formal parameters of the above
4 functions.
Additional instructions:
• Be sure to comment your code
• Include a program header with the following information:
o Name, due date, course, assignment number, professor name, and a brief description of the
assignment – see the sample skeleton provided with the assignment.
• Read all comments in the sample code before getting started
• Read the problem and determine what to do
• Write the algorithm (you DO NOT need to submit the algorithm)
• Implement one component at a time in your code and do not move onto the next component until you are sure
it is correct.
• Test your program before submitting
• One source code file (unformatted text) will be submitted
• The file name must match the assignment
• The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas
The sample output below has only 5 items.
You will need to update the input file which should have a minimum of 10
items. You can use the 5 already in the file and add at least 5 more or
create your own 10 items.
sports equipment order. Different locations have different tax rates.
The phone number (string), item name (string), item number (string), quantity (integer), unit price (double),
location ID (integer) will be read from an input file called sportsEquipment.txt
The input file has only 5 items.
You will need to update the input file which should have a minimum of 10 items.
You can use the 5 already in the file and add at least 5 more or create your
own 10 items.
Be sure the input file is in the same location as your source code!
Use the information below to determine the tax rate based on the location ID (locID ) , calculate the tax, netCost, and
totalCost for each line in the file and display the results onto the screen in columns using \t(tab), see the sample
output provided.
You can modify the way the information is presented on the screen, you do not
need to follow my sample output, but you must use some columns and all the
information must be printed onto the screen for each order.
o locID is 1– TAX rate is 7.25% (.0725)
o 2 <= locID <=5 – TAX rate is 7% (.07)
o 6 <= locID <= 7– TAX rate is 6.85% (.0685)
o 8 <= locID <= 15 – TAX rate is 6.5% (.065)
o 16 <= locID <= 27 – TAX rate is 6 % (.06)
o 28 <= locD <= 33 – TAX rate is 5.5% (.055)
o 34 <= locD <= 35 – TAX rate is 5% (.05)
o 36 <= locID <= 40 – TAX rate is 4.45% (.0445)
o 41 <= locID <= 45 – TAX rate is 4% (.04)
o locID is 46 – TAX rate is 2.90% (.0290)
o 47 <= locID <= 51 – TAX rate is 0% (.00)
o < 0 – is not a valid entry for the locID
o > 51– is not a valid entry for the locID
• Use a string for the users first name only as you interact with the user
Use the struct below to store the data for each record:
struct equipmentRecord
{
string cellNumber;
string itemName;
string itemNumber;
int quantity;
double price;
int locID;
double taxRate;
double tax;
double netCost;
double totalCost;
};
//BE SURE TO ADD COMMENTS TO THE FUNCTION PROTOTYPES (above main)
//AND TO THE FUNCITON DEFINITIONS (below main)
//USE pre and post conditions with descriptions
//see the sample provided
For program 3 you must use the following functions exactly as described below (same name and same formal
parameter data types in the same order):
void GetDataInput(ifstream&, equipmentRecord&);
void ProcessData(equipmentRecord&);
void GetTaxRate(double&, int);
void DisplayOutput(const equipmentRecord&);
All double output should be presented with 2 decimal places (see sample output)
** The purpose of the assignment is to practice using a struct, file input, and pass by reference parameters
You may add additional functions, but you MAY NOT modify the name or the formal parameters of the above
4 functions.
Additional instructions:
• Be sure to comment your code
• Include a program header with the following information:
o Name, due date, course, assignment number, professor name, and a brief description of the
assignment – see the sample skeleton provided with the assignment.
• Read all comments in the sample code before getting started
• Read the problem and determine what to do
• Write the algorithm (you DO NOT need to submit the algorithm)
• Implement one component at a time in your code and do not move onto the next component until you are sure
it is correct.
• Test your program before submitting
• One source code file (unformatted text) will be submitted
• The file name must match the assignment
• The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas
The sample output below has only 5 items.
You will need to update the input file which should have a minimum of 10
items. You can use the 5 already in the file and add at least 5 more or
create your own 10 items.
Related categories:
C++ Programming