//Jonathan Estrada CSC5 Chapter 11, P.645, #2
/*******************************************************************************
* COMPUTE PROFIT OR LOSS
* _____________________________________________________________________________
* This program accepts information for a number of a movies title, director,
* year released, run time, budget, and first year profit. Then the information
* will be displayed properly formatted showing if the movie gained or lost
* money.
* _____________________________________________________________________________
* INPUT
* SIZE : Number of movies
* title : Movie title
* director : Director of movie
* yearRelease : Year released
* runTime : Movie Runtime
* budget : movie budget
* firstYearRev : First year revenue
*
* OUTPUT
* profitOrLoss : amount profited or lost
*
* ****************************************************************************/
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct MovieData
{
string title;
string director;
int yearRelease;
float runTime;
double budget;
double firstYearRev;
};
int main()
{
int SIZE;
cout << "How how many movies do you want to enter information about: ";
cin >> SIZE;
cout << SIZE << endl << endl;
cin.ignore();
MovieData* movie = new MovieData[SIZE];
double profitOrLoss;
cout << "Please enter information for " << SIZE << " movie(s)." << endl;
for(int i = 0; i < SIZE; i++)
{
cout << "Title: ";
getline(cin, movie[i].title);
cout << "Direcetor: ";
getline(cin, movie[i].director);
cout << "Year Released: ";
cin >> movie[i].yearRelease;
cin.ignore();
cout << "Running TIme (in minutes): ";
cin >> movie[i].runTime;
cin.ignore();
cout << endl;
cout << "Movie Budget: ";
cin >> movie[i].budget;
cin.ignore();
cout << endl;
cout << "Movie's first year revenue: ";
cin >> movie[i].firstYearRev;
cin.ignore();
cout << endl;
}
for(int i = 0; i < SIZE; i++)
{
cout << "Inforamation for movie " << (i+1) << endl;
cout << "Title: " << movie[i].title << endl;
cout << "Director: " << movie[i].director << endl;
cout << "Year Released: " << movie[i].yearRelease << endl;
cout << "Running TIme (in minutes): " << movie[i].runTime << endl;
profitOrLoss = movie[i].firstYearRev - movie[i].budget;
cout << fixed << setprecision(2);
cout << "Profit or Loss: " << profitOrLoss << endl;
}
delete[] movie;
return 0;
}