fork download
  1. //Jonathan Estrada CSC5 Chapter 11, P.645, #1
  2. /*******************************************************************************
  3.  * MOVIE INFORMATION
  4.  * _____________________________________________________________________________
  5.  * This program accepts information for a number of a movies title, director,
  6.  * year released, and run time. Then the information will be displayed
  7.  * properly formatted.
  8.  * _____________________________________________________________________________
  9.  * INPUT
  10.  * SIZE : Number of movies
  11.  * title : Movie title
  12.  * director : Director of movie
  13.  * yearRelease : Year released
  14.  * runTime : Movie Runtime
  15.  *
  16.  * ****************************************************************************/
  17. #include <iostream>
  18. #include <string>
  19. using namespace std;
  20.  
  21. struct MovieData
  22. {
  23. string title;
  24. string director;
  25. int yearRelease;
  26. float runTime;
  27. };
  28.  
  29. int main()
  30. {
  31. int SIZE;
  32.  
  33.  
  34. cout << "How how many movies do you want to enter information about: ";
  35. cin >> SIZE;
  36. cout << SIZE << endl << endl;
  37. cin.ignore();
  38.  
  39. MovieData* movie = new MovieData[SIZE];
  40.  
  41. cout << "Please enter information for " << SIZE << " movie(s)." << endl;
  42. for(int i = 0; i < SIZE; i++)
  43. {
  44. cout << "Title: ";
  45. getline(cin, movie[i].title);
  46.  
  47. cout << "Direcetor: ";
  48. getline(cin, movie[i].director);
  49.  
  50. cout << "Year Released: ";
  51. cin >> movie[i].yearRelease;
  52. cin.ignore();
  53.  
  54. cout << "Running TIme (in minutes): ";
  55. cin >> movie[i].runTime;
  56. cin.ignore();
  57. cout << endl;
  58.  
  59. }
  60.  
  61. for(int i = 0; i < SIZE; i++)
  62. {
  63. cout << "Inforamation for movie " << (i+1) << endl;
  64. cout << "Title: " << movie[i].title << endl;
  65. cout << "Director: " << movie[i].director << endl;
  66. cout << "Year Released: " << movie[i].yearRelease << endl;
  67. cout << "Running TIme (in minutes): " << movie[i].runTime << endl;
  68. }
  69.  
  70. delete[] movie;
  71.  
  72.  
  73. return 0;
  74. }
Success #stdin #stdout 0.01s 5272KB
stdin
2
Shrek
Andrew Adamson, Vicky Jenson
2001
89
Shrek 2
Andrew Adamson, Conrad Vernon, and Kelly Asbury
2004
90
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): 
Title: Direcetor: Year Released: Running TIme (in minutes): 
Inforamation for movie 1
Title: Shrek
Director: Andrew Adamson, Vicky Jenson
Year Released: 2001
Running TIme (in minutes): 89
Inforamation for movie 2
Title: Shrek 2
Director: Andrew Adamson, Conrad Vernon, and Kelly Asbury
Year Released: 2004
Running TIme (in minutes): 90