1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#include <iostream>
#include <iomanip>
using namespace std;
const int MAX = 60;
class MovieData
{
public:
int year, time, year2, time2;
double cost, revenue, cost2, revenue2;
char title[MAX], director[MAX], title2[MAX], director2[MAX];
};
void GetData(MovieData&, MovieData&);
void ShowData(MovieData, MovieData);
int main ()
{
MovieData movie1, movie2;
GetData(movie1, movie2);
ShowData(movie1, movie2);
cout << "\n\n\n";
system ("pause");
return 0;
}
void GetData(MovieData &movie1, MovieData &movie2)
{
cout << "Enter the following information for the first movie.";
cout << "\n\n\nEnter the title of the movie: ";
cin.getline(movie1.title, MAX);
cout << "\nEnter the director of the movie: ";
cin.getline(movie1.director, MAX);
cout << "\nEnter the year the movie was released (4-Digits): ";
cin >> movie1.year;
while ((movie1.year < 1000) || (movie1.year > 9999))
{
cout << "\n\nInvalid Input.\n\n\nThe year cannot be lower or higher than 4 digits: ";
cin >> movie1.year;
}
cout << "\nEnter the running time of the movie in minutes: ";
cin >> movie1.time;
while (movie1.time < 60)
{
cout << "Invalid Input.\n\n\nA movie consists greater than 60 minutes: ";
cin >> movie1.time;
}
cout << "\nEnter the cost of the movie: ";
cin >> movie1.cost;
while (movie1.cost < 0)
{
cout << "Invalid Input.\n\n\nA movie cannot be lower than 0: $";
cin >> movie1.cost;
}
cout << "\nEnter the overall revenue the movie earned: $";
cin >> movie1.revenue;
while (movie1.revenue < 0)
{
cout << "Invalid Input.\n\n\nThe revenue cannot be lower than 0: $";
cin >> movie1.revenue;
}
cout << "\n\nEnter the following information for the second movie.";
cout << "\n\n\nEnter the title of the movie:" << " ";
cin.ignore();
cin.getline(movie2.title2, MAX);
cout << "\nEnter the director of the movie: ";
cin.getline(movie2.director2, MAX);
cout << "\nEnter the year the movie was released (4-Digits): ";
cin >> movie2.year2;
while ((movie2.year2 < 1000) || (movie2.year2 > 9999))
{
cout << "\n\nInvalid Input.\n\n\nThe year cannot be lower or higher than 4 digits: ";
cin >> movie2.year2;
}
cout << "\nEnter the running time of the movie in minutes: ";
cin >> movie2.time2;
while (movie2.time2 < 60)
{
cout << "Invalid Input.\n\n\nA movie consists greater than 60 minutes: ";
cin >> movie2.time2;
}
cout << "\nEnter the cost of the movie: ";
cin >> movie2.cost2;
while (movie2.cost2 < 0)
{
cout << "Invalid Input.\n\n\nA movie cannot be lower than 0: $";
cin >> movie2.cost2;
}
cout << "\nEnter the overall revenue the movie earned: $";
cin >> movie2.revenue2;
while (movie2.revenue2 < 0)
{
cout << "Invalid Input.\n\n\nThe revenue cannot be lower than 0: $";
cin >> movie2.revenue2;
}
cout << "\n\n";
}
void ShowData(MovieData movie1, MovieData movie2)
{
cout << "\n\nFirst Movie:";
cout << "\n\nMovie Title: " << setw(13) << movie1.title << "\n";
cout << "Director's Name: " << setw(8) << movie1.director << "\n";
cout << "Year Released: " << setw(11) << movie1.year << "\n";
cout << "Movie Runtime: " << setw(9) << movie1.time << "\n";
cout << "Movie Cost " << setw(11) << "$" << movie1.cost << "\n";
cout << "Movie Revenue " << setw(8) << "$" << movie1.revenue << "\n";
cout << "\n\nSecond Movie:";
cout << "\n\nMovie Title: " << setw(13) << movie2.title2 << "\n";
cout << "Director's Name: " << setw(8) << movie2.director2 << "\n";
cout << "Year Released: " << setw(11) << movie2.year2 << "\n";
cout << "Movie Runtime: " << setw(9) << movie2.time2 << "\n";
cout << "Movie Cost " << setw(11) << "$" << movie2.cost2 << "\n";
cout << "Movie Revenue " << setw(8) << "$" << movie2.revenue2 << "\n";
}
|