The High Fashion Department Store wants a program written to produce its monthly
ID: 3546248 • Letter: T
Question
The High Fashion Department Store wants a program written to produce
its monthly bills. Input to the program will be the customer number,
the number of the department in which that item was purchased, the item
number, and the amount of the purchase. There are four departments
numbered 1 through 4. On all purchases of $10.00 or more in departments
1 and 2 , the customer receives a 5 percent discount. On all purchases
of $25.00 or more in departments 3 and 4, the customer receives an 8
percent discount. Totals are to be produced for each department and
for each customer. Sales tax of 7 percent is paid on the net total for
the customer. Also a service charge is added to the bill if the amount
of the bill is less than $100.00. The service charge is 10 percent of
the net bill before the sales tax is added if the total is less than
$50.00. Otherwise, the service charge is 5 percent. The bill for each
customer is to be printed on a separate page. (You need a counter to
keep track of the number of print lines used.)
You have to use at least two functions for this assignment.
Make sure error checks are performed on the input data.
Sample Input
132 2 12 8.97
132 2 65 19.80
132 3 198 67.90
132 3 292 7.77
132 3 418 18.90
132 4 190 25.91
254 1 55 25.50
254 1 678 69.80
254 3 66 99.0
254 4 57 80.70
254 4 78 990.40
254 4 97 70.50
Explanation / Answer
#include #include #include #include using namespace std; #define in_file "data.txt" #define out_file "result.txt" void main () { ifstream ins; ofstream outs; //open file ins.open(in_file); outs.open(out_file); //declare variables and constants const double discount1 = 0.05; const double discount2 = 0.08; const double sales_tax = 0.07; const double service_charge1 = 0.10; const double service_charge2 = 0.05; int customer; int department; int item; int purchase; int discount; int net; int net_total; int total; int service_charge; int total_purchase, total_discount, subtotal, SalesTax; int counter = 0; if (!in_file) cout > department >> item >> purchase >> customer; counter++; //calculations if ( department == 3 || department == 4) { if ( purchase >= 25 ) { discount = purchase * 0.08; net = purchase - discount; } } if ( department == 1 || department == 2) { if ( purchase >= 10 ) { discount = purchase * 0.05; net = purchase - discount; } } if ( department = 1 ) { total_purchase += purchase; total_discount += discount; net_total += net; } if ( department = 2 ) { total_purchase += purchase; total_discount += discount; net_total += net; } if ( department= 3 ) { total_purchase += purchase; total_discount += discount; net_total += net; } if ( department = 4 ) { total_purchase += purchase; total_discount += discount; net_total += net; } net_total += net_total; SalesTax = (net_total * sales_tax); subtotal = net_total + SalesTax; if (subtotal < 100 && subtotal > 50) { service_charge = net_total * service_charge1; total = subtotal + service_charge; } if (subtotal < 50) { service_charge = net_total * service_charge2; total = subtotal + service_charge; } //bill display outsRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.