A paper copy of your program should be turned in at the beginning of
class.
Your work should be dropped off electronically in the Lamont folders by
10:00 AM on the due date.
Late Deadline: turn in by Midnight Friday Feb. 22 for a 10% penalty.
(Paper on my office door.)
For further details on how to hand in assignments, see these Submission
Guidelines.
You have two data files:
- one
describing movies and how much revenue they have produced
(Typical line: Spider_Man_3
336530303 )
- one
describing actors and the movies they have appeared in
(Typical line: John Smith Bridge_to_Terabithia
)
You can download sample files: revenues.txt actors.txt
Write a program that
- reads both files
(the file names are always revenues.txt
and actors.txt)
- calculates the earnings
of each actor assuming she earns 1% of the revenue
of each
film she appears in
- displays the total earnings
for each actor (in any order)
You program should
- define and use two structs,
one for movies and one for actors
- use an array of movie
structs and an array of actors
- include the following
functions
- main (which only calls other fuctions, < 10 lines long)
- a function that reads the revenues file (and fills up an array of movie
structs)
- a function that reads the actors file (and continuously changes an array
of actor structs)
- a function that finds the revenue earned by a given movie
- a function that adds a given amount to the total for a specified actor
- a function that displays all actor earnings
The correct output for the given sample input files is
John Smith $822724.42
Anne Smith $2928873.81
Matt Damon $4312460.54
Shia LaBoeuf $2907216.40
Daniel Radcliffe $2898996.66
Kirstin Dunst $3365303.03
Marge Simpson $3923336.63
Press any key to continue . .
The problem can be solved in about 100 lines of code.
As always, no global variables!
How to print dollar amounts:
#include <iomanip>
. . .
cout << "$" << fixed
<< setprecision(2) << someDoubleVar;