Description: You are shopping at your favorite store. You select one item
of merchandise marked at a listed price. At the checkout, you
are asked whether you have a coupon. If not, you will be
charged the regular price. If you have a coupon, the cashier
will determine whether it is a cash-off coupon, or a percent-off
coupon. A cash-off coupon will reduce the marked price by a
fixed amount; a percent off-off coupon will reduce the price
by a percentage.
================
INPUT FILE: (shoppers.dat) NOTE: not every line has 4 items!!!
coupontype and couponvalue given ONLY when
couponused is Y.
CONTENT:
itemcost couponused [coupontype couponvalue]
FORMAT:
xxx.xx x x xxx.xx
EXAMPLE:
49.99 Y C 2.49
80.00 Y P 25.00
280.00 N
87.33 Y P 100.00
2.99 Y C 2.00
SCREEN OUTPUTS: (same as PROG6a) PLUS ...
Error Message: FATAL ERROR - CAN NOT OPEN FILE shoppers.dat
when input file can not be found/opened.
============================================================
ALGORITHM:
============================================================
...
int main()
{
// Declare variables.
ifstream shopperF("shoppers.dat");
//-| PROCESS ONE SHOPPER
1. Open input file.
1.1 Display following message and exit if file can not be opened.
"FATAL ERROR - CAN NOT OPEN FILE shoppers.dat"
2. Read regularPrice, couponUsed.
**************************************
shopperF >> regularPrice >> couponUsed;
**************************************
3. If coupon is used
3.1 Read couponType, couponValue;
**************************************
shopperF >> couponType >> couponValue;
3.2 if type is C
3.2.1 Compute Savings = couponValue
3.3 else
3.3.1 Compute Savings = regularPrice * couponValue/100.0
3.4 Compute amountPaid = regularPrice - Savings
3.5 Display regularPrice, couponType, Savings, amountPaid.
4. else
4.1 Compute amountPaid = regularPrice
4.2 Display regularPrice, amountPaid.
5. close input file.
}
coupons_b.cpp:2: parse error before `--' token
In file included from /usr/local/include/c++/3.2.2/iosfwd:45,
from /usr/local/include/c++/3.2.2/ios:44,
from /usr/local/include/c++/3.2.2/ostream:45,
from /usr/local/include/c++/3.2.2/iostream:45,
from coupons_b.cpp:31:
/usr/local/include/c++/3.2.2/bits/stringfwd.h:55: parse error before `<' token
/usr/local/include/c++/3.2.2/bits/stringfwd.h:58: confused by earlier errors, bailing out