fork download
  1. //Charlotte Davies-Kiernan CS1A Chapter 11 P. 645 #1
  2. //
  3. /******************************************************************************
  4.  *
  5.  * Display Movie Information
  6.  * ____________________________________________________________________________
  7.  * This program will display the title, director, year released, and running
  8.  * time of two different movies
  9.  * ____________________________________________________________________________
  10.  * Input
  11.  * title :Title of the two movies
  12.  * director :Director of the two movies
  13.  * yearReleased :Year both the movies were released
  14.  * runningTime :Amount of time the movies last
  15.  * movie1 :First movie
  16.  * movie2 :Second Movie
  17.  * Output
  18.  * displayMovie :Function that displays both the movies information
  19.  *****************************************************************************/
  20. #include <iostream>
  21. #include <string>
  22. using namespace std;
  23.  
  24. //Structure Definition
  25. struct MovieData {
  26. string title;
  27. string director;
  28. int yearReleased;
  29. int runningTime;
  30. };
  31.  
  32. //Function Prototype
  33. void displayMovie(const MovieData &);
  34.  
  35. int main() {
  36. //Data Dictionary
  37. MovieData movie1 = {"Inception", "Christopher Nolan", 2010, 148};
  38. MovieData movie2 = {"The Matrix", "The Wachowskis", 1999, 136};
  39.  
  40. displayMovie(movie1);
  41. displayMovie(movie2);
  42.  
  43. return 0;
  44. }
  45.  
  46. //Function Definition
  47. void displayMovie(const MovieData &movie) {
  48. cout << "Movie Information: " << endl;
  49. cout << "Title: " << movie.title << endl;
  50. cout << "Director: " << movie.director << endl;
  51. cout << "Year Released: " << movie.yearReleased << endl;
  52. cout << "Running Time: " << movie.runningTime << endl;
  53. cout << endl;
  54. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Movie Information: 
Title: Inception
Director: Christopher Nolan
Year Released: 2010
Running Time: 148

Movie Information: 
Title: The Matrix
Director: The Wachowskis
Year Released: 1999
Running Time: 136