Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DATA FILE DESCRIPTION A file contains data for a day's worth of purchases made at a small store. The data file is structured as follows:

DATA FILE DESCRIPTION A file contains data for a day's worth of purchases made at a small store. The data file is structured as follows:

The first 3 integers in the file are the year, month, and day of the purchases (in that order).

The remainder of the file is made of up several sets of customer purchases. Each purchase set will begin with a receipt number (integer with a maximum of 4 digits)

The receipt number will be followed by data for the items purchased.

The data for each item, is as follows

item id# - an integer that is used to identify the item for inventory and sale purposes

regular price - the regular sales price of the item, may include a decimal

percent off - an integer that indicates the current percentage discount on the item - for example, if the value is 20, then the item is on sale for 20% off the regular price (if item is not on sale, this value will be 0)

number purchased - integer that represents how many of the item was purchased

tax status - a single character N or T - N means that sales tax should not be charged on the purchase price, T means that sales tax should be applied to the price (after any discount)

Each purchase set will be terminated by an item id# of 0 (sentinel).

Sample data file: 2017 3 12 4223 161 10.0 0 2 T 99 5.00 10 3 T 0 581 123 45.00 10 3 T 921 5.25 0 1 N 83 14.99 25 2 T 0

PROGRAM SPECIFICATIONS Design a C++ program that will read the input from the data file using Linux redirection and do the following:

the sales tax rate is 5%

display your name, lecture section #, and assignment #, followed by at least one blank line

display the date of the purchases formatted as month/day/year

for each purchase set, display the receipt number (with label) then display the following for each item

the item id# (left justified)

regular price ($, right justified, 2 digits to right of decimal)

sale percentage (right justified, as an integer, with % sign)

sale price ($, right justified, 2 digits to right of decimal)

# purchased (right justified, as an integer)

total cost of item ($, right justified, 2 digits to right of decimal)

sales tax ($, right justified, 2 digits to right of decimal)

after all items for the purchase set have been processed, display 3 additional lines - all values should line up with the total cost column ($, right justified, 2 digits to right of decimal for all 3 values)

the total for the total cost column

the total for the sales tax column

total amount due for the purchase set

continuing processing untill all purchase sets (receipts) in the file have been read

when all data in the file has been read and processed, display messages that include the date and

the total amount of sales (not including sales tax, with $ and 2 digits to right of decimal)

the total amount of sales tax collected (with $ and 2 digits to right of decimal)

see example below for format to follow -

max length of item id# will be 4 digits

max original price will be $999.99

max % off will be 99%

max quantity will be 99

max space required to display totals will be 10 columns

DO NOT ATTEMPT TO USE SEPARATE FUNCTIONS TO WRITE THIS PROGRAM.

NOTE: Values displayed may be a penny off due to round-off issues, (see example below). Do NOT try to fix this problem.

Test your program adequately! Documentation When the program compiles and runs correctly, add the following documentation (comments) to your source file (.cpp file).At the start of the program file,

Place a comment with your name, lecture section#, and assignment # at the beginning of the file.

List the expected input to the program. Be specific.

List the expected output of the program. Be specific. (If the input values are supposed to be displayed, include them in the output list.)

When a named constant and/or major variable is declared, provide a meaningful description of what it represents in the program.

Sample terminal session: [lee@bobby keys]$ more data4two 2017 3 12 4223 161 10.0 0 2 T 99 5.00 10 3 T 0 581 123 45.00 10 3 T 921 5.25 0 1 N 83 14.99 25 2 T 0 [lee@bobby keys]$ g++ assign02.cpp [lee@bobby keys]$ ./a.out < data4two Lee Misch LecSec #10__ Assignment #2 Date of purchases: 3/12/2017 Receipt #4223 ITEM ORIGINAL PCT SALES TOTAL SALES ID# PRICE OFF PRICE QTY COST TAX 161 $ 10.00 0% $ 10.00 2 $ 20.00 $ 1.00 99 $ 5.00 10% $ 4.50 3 $ 13.50 $ 0.68 SUBTOTAL $ 33.50 SALES TAX $ 1.68 TOTAL DUE $ 35.17 Receipt #581 ITEM ORIGINAL PCT SALES TOTAL SALES ID# PRICE OFF PRICE QTY COST TAX 123 $ 45.00 10% $ 40.50 3 $ 121.50 $ 6.08 921 $ 5.25 0% $ 5.25 1 $ 5.25 $ 0.00 83 $ 14.99 25% $ 11.24 2 $ 22.48 $ 1.12 SUBTOTAL $ 149.24 SALES TAX $ 7.20 TOTAL DUE $ 156.43 Total sales for 3/12/2017 were $182.74 Total sales tax collected for 3/12/2017 was $8.87

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

=+4 What are non-union workers representations?

Answered: 1 week ago