– Program 1 - Sales Tax - Fall 2011 CMPS 1043

advertisement
CMPS 1043 – Program 1 - Sales Tax - Fall 2011
Problem Solving Steps Due: Fri., Sept. 16 / Thurs., Sept. 15
Program Due: Mon., Sept. 19 / Tues., Sept. 20
You are to write a C++ program for calculating and displaying a retail purchase and the sales tax. The
program will loop 10 times and process 10 different purchases.
The program is to prompt the user for the purchase amount which will be typed in at the keyboard.
Based on the following sales tax values & print out a sales receipt that looks as shown below.
State sales tax is 5%. City sales tax is 3.25%. (Declare as constants.)
Purchase amount
State sales tax
City sales tax
Total sales amount
$ 100.00
$
5.00
$
3.25
----------$ 108.25
Print your name before processing any of the data and place a blank line before and after each of
the10 purchase reports. (Don’t worry about the number of decimal places; just accept the number
printed.
Use type double for all variables. Be sure to include user prompts asking for data.
Use the following main function template to cause the program to execute 10 times for different data
values. Check your output by hand, making sure your answers are correct. Comment your program
as discussed in lab and class.
#include <iomanip>
// include this new directive
int main (void)
{
int count;
...... PUT YOUR DECLARATIONS HERE ......
count = 1;
cout << fixed << setprecision(2); //also use with file output
//will print 2 decimal places
...... PUT OTHER NEEDED STATEMENTS HERE ......
while (count <= 10)
{ ... PUT YOUR PROGRAM STATEMENTS HERE...
count = count + 1;
}
return 0;
}
Use cout statements to print to the screen until you have the program running completely.
(Calculate using a calculator to verify that all your answers are correct.) Then convert to file output.
You will need to include all the commands related to an output file as covered in Lab 2 so that your
results will be placed in your output file. Print your program file and output file to turn in.
Use the following data for executing your program:
100 4.23 9064.98 75.00
10000 25.25
1456.90
0.99
9030.02
45623.00
Download