//Devin Scheu CS1A Chapter 11, P. 645, #2
//
/**************************************************************
*
* DISPLAY MOVIE INFORMATION WITH PROFIT OR LOSS
* ____________________________________________________________
* This program displays information about two movies, including
* their profit or loss for the first year.
* ____________________________________________________________
* INPUT
* movie1 : The data for the first movie
* movie2 : The data for the second movie
*
* OUTPUT
* movieDetails : The formatted display of movie information and profit/loss
*
**************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct MovieData {
string title;
string director;
int yearReleased;
int runningTime;
double productionCosts;
double firstYearRevenues;
};
// Function to display movie information including profit/loss
void displayMovie(const MovieData& movie) {
double profitLoss = movie.firstYearRevenues - movie.productionCosts;
cout << left << setw(25) << "Title:" << right << movie.title << endl;
cout << left << setw(25) << "Director:" << right << movie.director << endl;
cout << left << setw(25) << "Year Released:" << right << movie.yearReleased << endl;
cout << left << setw(25) << "Running Time:" << right << movie.runningTime << " minutes" << endl;
cout << left << setw(25) << "Production Costs:" << right << "$" << fixed << setprecision(2) << movie.productionCosts << endl;
cout << left << setw(25) << "First Year Revenues:" << right << "$" << fixed << setprecision(2) << movie.firstYearRevenues << endl;
cout << left << setw(25) << "First Year Profit/Loss:" << right << "$" << fixed << setprecision(2) << profitLoss << endl;
cout << endl;
}
int main () {
//Variable Declarations
MovieData movie1; //INPUT - The data for the first movie
MovieData movie2; //INPUT - The data for the second movie
string movieDetails; //OUTPUT - The formatted display of movie information and profit/loss
//Initialize Movie 1
movie1.title = "The Shawshank Redemption";
movie1.director = "Frank Darabont";
movie1.yearReleased = 1994;
movie1.runningTime = 142;
movie1.productionCosts = 25000000.00;
movie1.firstYearRevenues = 58000000.00;
//Initialize Movie 2
movie2.title = "Inception";
movie2.director = "Christopher Nolan";
movie2.yearReleased = 2010;
movie2.runningTime = 148;
movie2.productionCosts = 160000000.00;
movie2.firstYearRevenues = 825000000.00;
//Separator and Output Section
cout << "-------------------------------------------------------" << endl;
cout << "OUTPUT:" << endl;
//Display Movie Information
cout << "Movie 1 Details:" << endl;
displayMovie(movie1);
cout << "Movie 2 Details:" << endl;
displayMovie(movie2);
} //end of main()