fork download
  1. //Jonathan Estrada CSC5 Chapter 11, P.645, #2
  2. /*******************************************************************************
  3.  * COMPUTE PROFIT OR LOSS
  4.  * _____________________________________________________________________________
  5.  * This program accepts information for a number of a movies title, director,
  6.  * year released, run time, budget, and first year profit. Then the information
  7.  * will be displayed properly formatted showing if the movie gained or lost
  8.  * money.
  9.  * _____________________________________________________________________________
  10.  * INPUT
  11.  * SIZE : Number of movies
  12.  * title : Movie title
  13.  * director : Director of movie
  14.  * yearRelease : Year released
  15.  * runTime : Movie Runtime
  16.  * budget : movie budget
  17.  * firstYearRev : First year revenue
  18.  *
  19.  * OUTPUT
  20.  * profitOrLoss : amount profited or lost
  21.  *
  22.  * ****************************************************************************/
  23. #include <iostream>
  24. #include <string>
  25. #include <iomanip>
  26. using namespace std;
  27.  
  28. struct MovieData
  29. {
  30. string title;
  31. string director;
  32. int yearRelease;
  33. float runTime;
  34. double budget;
  35. double firstYearRev;
  36.  
  37. };
  38.  
  39. int main()
  40. {
  41. int SIZE;
  42.  
  43.  
  44. cout << "How how many movies do you want to enter information about: ";
  45. cin >> SIZE;
  46. cout << SIZE << endl << endl;
  47. cin.ignore();
  48.  
  49. MovieData* movie = new MovieData[SIZE];
  50. double profitOrLoss;
  51.  
  52. cout << "Please enter information for " << SIZE << " movie(s)." << endl;
  53. for(int i = 0; i < SIZE; i++)
  54. {
  55. cout << "Title: ";
  56. getline(cin, movie[i].title);
  57.  
  58. cout << "Direcetor: ";
  59. getline(cin, movie[i].director);
  60.  
  61. cout << "Year Released: ";
  62. cin >> movie[i].yearRelease;
  63. cin.ignore();
  64.  
  65. cout << "Running TIme (in minutes): ";
  66. cin >> movie[i].runTime;
  67. cin.ignore();
  68. cout << endl;
  69.  
  70. cout << "Movie Budget: ";
  71. cin >> movie[i].budget;
  72. cin.ignore();
  73. cout << endl;
  74.  
  75. cout << "Movie's first year revenue: ";
  76. cin >> movie[i].firstYearRev;
  77. cin.ignore();
  78. cout << endl;
  79.  
  80.  
  81. }
  82.  
  83. for(int i = 0; i < SIZE; i++)
  84. {
  85. cout << "Inforamation for movie " << (i+1) << endl;
  86. cout << "Title: " << movie[i].title << endl;
  87. cout << "Director: " << movie[i].director << endl;
  88. cout << "Year Released: " << movie[i].yearRelease << endl;
  89. cout << "Running TIme (in minutes): " << movie[i].runTime << endl;
  90. profitOrLoss = movie[i].firstYearRev - movie[i].budget;
  91. cout << fixed << setprecision(2);
  92. cout << "Profit or Loss: " << profitOrLoss << endl;
  93. }
  94.  
  95. delete[] movie;
  96.  
  97.  
  98. return 0;
  99. }
  100.  
Success #stdin #stdout 0s 5288KB
stdin
2
Shrek
Andrew Adamson, Vicky Jenson
2001
89
60000000
484400000
Shrek 2
Andrew Adamson, Conrad Vernon, and Kelly Asbury
2004
90
150000000
935300000
stdout
How how many movies do you want to enter information about: 2

Please enter information for 2 movie(s).
Title: Direcetor: Year Released: Running TIme (in minutes): 
Movie Budget: 
Movie's first year revenue: 
Title: Direcetor: Year Released: Running TIme (in minutes): 
Movie Budget: 
Movie's first year revenue: 
Inforamation for movie 1
Title: Shrek
Director: Andrew Adamson, Vicky Jenson
Year Released: 2001
Running TIme (in minutes): 89
Profit or Loss: 424400000.00
Inforamation for movie 2
Title: Shrek 2
Director: Andrew Adamson, Conrad Vernon, and Kelly Asbury
Year Released: 2004
Running TIme (in minutes): 90.00
Profit or Loss: 785300000.00