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

For the following C++ codes, help me fix it so that its outcome would display th

ID: 3859302 • Letter: F

Question

For the following C++ codes, help me fix it so that its outcome would display the profit or loss, which equals to (first year revenue - production cost) [which the user enters]

Thanks!

#include #include using namespace std; struct MovieData string title; string director; int year released int runningtime int production cost; int first yearrevenue // Function prototypes MovieData getMovieData) void printMovieData(MovieData*); int main() // Variables MovieData m1, m2; MovieData *ptr1, *ptr2; ptr1 = &m1; ptr2 = &m2; // Call getMovieData function to get information for both movies m1 = getMovieData m2 = getMovieData(); // Call printMovidata function to print information for both movies rintMovieData(ptrl); cout

Explanation / Answer

//Please see the below fixed code and it's output please do thumbs up if you like the solution

#include<iostream>
#include <string>
using namespace std;

struct MovieData
{
string title;
string director;
int year_released;
int running_time;
int production_cost;
int first_year_revenue;
};

//Function prototype
MovieData getMovieData();
void printMovieData(MovieData *);

int main()
{
   //Variable
   MovieData m1,m2;
   MovieData *ptr1,*ptr2;
   ptr1=&m1;
   ptr2=&m2;
   //call MovieData function to get information for both movies
   m1=getMovieData();
   m2=getMovieData();
   //call printMovieData function to print information for both movies.
    printMovieData(ptr1);
   cout<<" ";
   printMovieData(ptr2);
   system("PAUSE");
   return 0;
}

MovieData getMovieData()
{
  
   MovieData temp;
   cout <<"Enter the title of the movie:";
//   cin.getline(movie.title);
   getline(cin,temp.title);
    cout << " ";
   cout <<"Enter the name of the movie director:";
   getline(cin,temp.director);
   cout << " ";
   cout <<"Enter the year the movie was released:";
   cin>>temp.year_released;
   cout << " ";
    cout <<"Enter the running time of the movie(in minutes):";
   cin>>temp.running_time;
   cout << " ";
   cout <<"Enter the production cost of the movie: $";
   cin>>temp.production_cost;
   cout << " ";
   cout <<"Enter the movie's first year revenue: $";
   cin>>temp.first_year_revenue;
   cout << " ";

   cin.ignore();
   return temp;

}

void printMovieData(MovieData *m)
{
   cout<<" ";
   cout<<" ";
   cout<<"Title: "<<m->title<<endl;
   cout<<"Director: "<<m->director<<endl;
   cout<<"Year released: "<<m->year_released<<endl;
   cout<<"Running Time: "<<m->running_time<<endl;
   cout<<"Production Cost: "<<m->production_cost<<endl;

   if(m->first_year_revenue >m->production_cost)
       cout<<"The First Year Profit is $ "<<m->first_year_revenue - m->production_cost;
   else
       cout<<"The First Year Profit is $ "<<m->first_year_revenue - m->production_cost;
   cout<<" ";
}

OUTPUT:

Enter the title of the movie:DON

Enter the name of the movie director:ABCD

Enter the year the movie was released:2015

Enter the running time of the movie(in minutes):300

Enter the production cost of the movie: $10000

Enter the movie's first year revenue: $20500

Enter the title of the movie:
Enter the name of the movie director:Matrix

Enter the year the movie was released:1998

Enter the running time of the movie(in minutes):300

Enter the production cost of the movie: $20000

Enter the movie's first year revenue: $50000

Title: DON
Director: ABCD
Year released: 2015
Running Time: 300
Production Cost: 10000
The First Year Profit is $ 10500

Title:
Director: Matrix
Year released: 1998
Running Time: 300
Production Cost: 20000
The First Year Profit is $ 30000
Press any key to continue . . .