fork(1) download
  1. //Sam Trivikraman CS1A Chapter 11, p. 645, #1
  2. //
  3. /*
  4.  ******************************************************************************
  5. Store Movie Data
  6. _______________________________________________________________________________
  7. This program stores user inputted movie data.
  8. _______________________________________________________________________________
  9. INPUT
  10. movie title : The title of the movie
  11. movie director : The director of the movie
  12. movie release year : The movie's release year
  13. movie run time : The movie's run time
  14.  
  15. OUTPUT
  16. array of movie details : An array that stores all of the details for the movie
  17. _______________________________________________________________________________
  18. *******************************************************************************
  19. */
  20.  
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. //a structure that stores all of the movie data
  25. struct MovieData
  26. {
  27. string title; //INPUT movie title
  28. string director; //INPUT movie director
  29. int yearReleased; //INPUt movie year released
  30. int runTime; //INPUt movie run time
  31. };
  32.  
  33. int main() {
  34. // your code goes here
  35.  
  36. MovieData movieOne; //OUTPUT the first movie
  37. MovieData movieTwo; //OUTPUT the second movie
  38.  
  39. //ask user for the movie details for the first movie
  40. cout << "Please enter the title of the first movie" << endl;
  41. cin >> movieOne.title;
  42. cout << "Please enter the director of the first movie" << endl;
  43. cin >> movieOne.director;
  44. cout << "Please enter the year that the first movie was released" << endl;
  45. cin >> movieOne.yearReleased;
  46. cout << "Please enter the first movie's run time (in minutes)" << endl;
  47. cin >> movieOne.runTime;
  48.  
  49. //ask user for the movie details for the second movie
  50. cout << "Please enter the title of the second movie" << endl;
  51. cin >> movieTwo.title;
  52. cout << "Please enter the director of the second movie" << endl;
  53. cin >> movieTwo.director;
  54. cout << "Please enter the year that the second movie was released" << endl;
  55. cin >> movieTwo.yearReleased;
  56. cout << "Please enter the second movie's run time (in minutes)" << endl;
  57. cin >> movieTwo.runTime;
  58.  
  59. //Output the details for movie 1
  60. cout << "Movie One details: " << endl;
  61. cout << "Title: " << movieOne.title << endl;
  62. cout << "Director: " << movieOne.director << endl;
  63. cout << "Release Year: " << movieOne.yearReleased << endl;
  64. cout << "Run Time: " << movieOne.runTime << endl;
  65.  
  66. //Output the details for movie 2
  67. cout << "Movie Two details: " << endl;
  68. cout << "Title: " << movieTwo.title << endl;
  69. cout << "Director: " << movieTwo.director << endl;
  70. cout << "Release Year: " << movieTwo.yearReleased << endl;
  71. cout << "Run Time: " << movieTwo.runTime << endl;
  72. return 0;
  73. }
Success #stdin #stdout 0.01s 5276KB
stdin
Dune
bob
2022
176
wee
you
1679
556
stdout
Please enter the title of the first movie
Please enter the director of the first movie
Please enter the year that the first movie was released
Please enter the first movie's run time (in minutes)
Please enter the title of the second movie
Please enter the director of the second movie
Please enter the year that the second movie was released
Please enter the second movie's run time (in minutes)
Movie One details: 
Title: Dune
Director: bob
Release Year: 2022
Run Time: 176
Movie Two details: 
Title: wee
Director: you
Release Year: 1679
Run Time: 556