Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
[90pts]
Write a program hw.cpp that works as follows:
File not found! and exit.
add amount lbs name
—
which adds amount lbs of fruit name to
the current orderError! name not found!
price name
—
which prints the price of the fruit name
formatted as in this example:
blueberries are $1.59 per pound
Error! name not found!
checkout
—
which exits the program, printing out the total price
of the order in the format: total is $num
Requirement: Use an array or arrays containing struct objects!
| Sample Runs | ||
~/$ ./hw Filename: fruit1.txt command: add 3 lbs mango command: price asdf Error! asdf not found! command: price peaches Error! peaches not found! command: price blueberries blueberries are $1.59 per pound command: add 2.1 lbs blueberries command: checkout total is $5.469 |
~/$ ./hw Filename: fruit2.txt command: add 2.0 lbs oranges command: price kiwi kiwi are $1.07 per pound command: price starfruit Error! starfruit not found! command: add 1.5 lbs peas Error! peas not found! command: add 1.5 lbs plums command: checkout total is $2.505 |
~/$ ./hw Filename: foobar.txt File not found! |
~/bin/submit -c=IC210 -p=hw30 hw.cpp