Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have this bit of code over here. Basically, it asks the userto enter informati

ID: 3614830 • Letter: I

Question

I have this bit of code over here. Basically, it asks the userto enter information about a movie. I need it to do it for twomovies. The code works just fine for the first movie, using theloop. But when it loops to the second movie, it skips the firstquestion which is the title of the movie, and just goes to thedirector. I dont know what I'm doing wrong.
Lifesaver rating to anyone that can help me fix this.
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }
I have this bit of code over here. Basically, it asks the userto enter information about a movie. I need it to do it for twomovies. The code works just fine for the first movie, using theloop. But when it loops to the second movie, it skips the firstquestion which is the title of the movie, and just goes to thedirector. I dont know what I'm doing wrong.
Lifesaver rating to anyone that can help me fix this.
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }

Lifesaver rating to anyone that can help me fix this.
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }

Explanation / Answer

please rate - thanks when you input data enters remain in the input buffer after readingnumbers, you must clear the buffer of any extra enters( ), or thegetline will see it as the end if its data #include using namespace std; struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes }; //function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData); int main() { MovieData films[2]; for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); } return 0; } //function definition for ReadMovieData void ReadMovieData(MovieData &movies) { cout movies.runningTime; cin.ignore(1000, ' '); } //function definition for DisplayMovieData void DisplayMovieData(MovieData display) { cout