ONLY IN C++
Assignment purpose: simple i/o in C++, control structures (if/
else if/ else), simple math in C++, data types string,
double,
and int, formatting output in C++, functions, call by value and
call by reference.
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. Use the information below to determine the tax
rate based on the location ID (locID )
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
Information about each order:
• Use a string for the cell phone number
• Use a string for the item name
o You can use strings with no white space, example
soccer_ball
o If you want to read in strings with white space, use getline,
example soccer ball
▪ See more information about getline in the attached document:
getline.pdf
▪ Assignments will be graded using strings with no white
space
• Use a string for the item number (no white space)
• Use a string for the user letter input (“y” or “n”)
• Use int and double, not float
• Use a loop to allow the user to continue to make
calculations
o The user will enter “y” or “Y” to continue OR “n” or “N” to
stop
• You do not need to force the user to enter y or n
• The tax on the order is calculated by multiplying the quantity *
price * taxRate /100
o Note: drop the 100 if you converted the rate from
percentage
• The net cost is calculated by multiplying the quantity times the
price
• The total cost will be calculated by adding the netCost and the
tax.
• All double output should be presented with 2 decimal places
• Use four functions to break up the program (functions may not be
modified)
//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 2 you must use the following functions exactly as
described above (same name and same formal
parameter data types in the same order):
void GetDataInput(string&, string&, string&, int&,
double&, int&);
void GetTaxRate(double&, int);
void CalculateResults(int, double, double, double&,
double&, double&);
void DisplayOutput(string, string, string, int, double, int,
double, double, double, double);
These 4 functions MUST be called from the main function.
** The purpose of the assignment is to practice pass by value and
pass by reference function parameters.
You may add additional functions, but you MAY NOT modify the name
or the formal parameters of the above
4 functions.
The user will be prompted and enter the information one by
one:
• phone number (as a string)
• item name (string)
• the item number (as a string)
• the quantity (as an integer)
• the unit price (as a double)
• and the location ID (as an integer).
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 code must be submitted on time in order to receive credit
(11:59 PM on the due date)
• Late submissions will not be accepted or graded
All programming assignments are individual work, sharing code is
considered cheating
SAMPLE OUTPUT:
Enter your first name: Alex
Enter the cell phone number: 5611231234
Enter the item name? baseball_bat
Enter the item number? qwAs-rqwst123
Enter the quantity? 50
Enter the price? 35.00
Enter the location ID number? 200
Please enter a valid location ID between 1 and 51.
Enter the location ID number? 0
Please enter a valid location ID between 1 and 51.
Enter the location ID number? 3
tax rate is 0.07
Cell number: 5611231234
Item name is: baseball_bat
Item number: qwAs-rqwst123
Quantity: 50
Price: 35.00
Location number: 3
Tax rate: 0.07
Net cost: $1750.00
Order tax: $122.50
total cost: $1872.50
Tami, would you like to do another calculation (Y or N):
y
Enter the cell phone number: 5616667777
Enter the item name? baseball_glove
Enter the item number? xvyA-f1455a
Enter the quantity? 50
Enter the price? 79.99
Enter the location ID number? 44
tax rate is 0.04
Cell number: 5616667777
Item name is: baseball_glove
Item number: xvyA-f1455a
Quantity: 50
Price: 79.99
Location number: 44
Tax rate: 0.04
Net cost: $3999.50
Order tax: $159.98
total cost: $4159.48
Alex, would you like to do another calculation (Y or N):
n
Have a great day, Alex!
ONLY IN C++ Assignment purpose: simple i/o in C++, control structures (if/ else if/ else), simple math in C++, data type
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am