Question

In: Computer Science

Modify the program written for Module 2 Activity 1 (Movie Data) to include two additional members...

Modify the program written for Module 2 Activity 1 (Movie Data) to include two additional members that hold the movie's production costs and first-year revenues. Modify the function that displays the movie data to display the title, director, release year, running time, and first year's profit or loss.

Solutions

Expert Solution

Source Code:

#include <iostream>

using namespace std;

const int SIZE= 50;

struct MovieData
{
        char title[SIZE];
        char directors [SIZE];
        int year [SIZE];
        int runTime[SIZE];
        int cost[SIZE];
        int revenue[SIZE];
};

void GetMovieData (MovieData movieArray[], int size);
void GetCostRev (MovieData movieArray [], int size);
void printMovieData(MovieData movieArray[], int size);
int ProfitOrLoss(MovieData movieArray[], int size);

int main()
{
        const int size1=50;
        const int size2=50;

        MovieData movie1[size1], movie2[size2];

        GetMovieData (movie1, size1);
        printMovieData (movie1, size1);

        GetMovieData (movie2, size2);
        printMovieData (movie2, size2);

        GetMovieData (movie1, size1);
        printMovieData (movie1, size1);

        GetMovieData (movie2, size2);
        printMovieData (movie2, size2);

        return 0;


}
void GetMovieData(MovieData movieArray[], int size)
{
        
        cout <<"Enter the title of the Movie: ";
        cin >>movieArray[size].title;

        cout <<"Enter the name of the directors: ";
        cin >>movieArray[size].directors;
        
        //cout <<"Enter the release date of the movie: ";
//      cin >>movieArray[].year;

//      cout <<"Enter the running time of the movie in minutes: ";
//      cin >>movieArray[].runTime;
}

void GetCostRev(MovieData movieArray[], int size)
{ 
        cout <<"What is the costs of " <<endl;
        cout <<"the movie " <<movieArray[size].title <<" ? " ;
        //cin >> movieArray[size].cost;
        //cout<< "What were its revenues?: " ;
        //cin >> movieArray[size].revenue;
}

int ProfitOrLoss (MovieData movieArray[], int size)
{
        int profit=0, loss= 0;

        if (movieArray[size]. revenue)
        {
                profit+=movieArray[size].revenue - movieArray[size].cost;
                cout <<endl;
                cout<<"First Years profits: " <<profit <<endl;
                cout <<endl;

                return profit;
        }
        if(movieArray[size].cost > movieArray[size].revenue)
        {
                loss +=movieArray[size].revenue - movieArray[size].cost;

        cout <<endl;
        cout <<"First years loss: " <<loss<<endl;
        cout <<endl;

        }
        return loss;
}
void printMovieData(MovieData movieArray[], int size)
{
        cout <<endl <<endl;
        cout<<"-----------------------------------------------" <<endl;
        cout<< "\t\t Movie Data      "<<endl;
        cout <<"---------------------------------------------------"<<endl;
        cout <<"Movie Title                              |" <<movieArray[size].title <<endl;
        cout <<"                                         |" <<endl;
        cout <<"Director                                 |" <<movieArray[size].directors<<endl;
        cout <<"                                         |" <<endl;
        cout <<"Release Year                             |" <<movieArray[size].year <<endl;
        cout <<"                                         |" <<endl;
        cout <<"Movie Runtime in minutes                 |" <<movieArray[size].runTime <<endl;
        cout <<"                                         |" <<endl;
        cout <<endl;
}
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

Related Solutions

C++ 1. Modify this program to open the file "Customers.dat" so that all data is written...
C++ 1. Modify this program to open the file "Customers.dat" so that all data is written to the end of the file AND to allow the file to be read. 2. Create a method called "getLargestCustomerNumber" and call it after the "Customers.dat" file has been opened. Read all the existing customerNumbers and determine the largest customerNumber - do not assume the last record in the file is the largest number. Use this number as the base when adding new customer...
Module 07 Written Assignment - C-Diff Your written assignment for this module should be a 1-2...
Module 07 Written Assignment - C-Diff Your written assignment for this module should be a 1-2 page paper (not including title page and reference page) that describes the following: -You are caring for a patient with c-diff as part of your workload assignment. Discuss what c-diff is and how it is transmitted (how you can get it)? -What actions will you take as a nurse to protect yourself and the other patients on the unit when taking care of your...
Modify the Movie List 2D program -Modify the program so it contains four columns: name, year,...
Modify the Movie List 2D program -Modify the program so it contains four columns: name, year, price and rating (G,PG,R…) -Enhance the program so it provides a find by rating function that lists all of the movies that have a specified rating def list(movie_list): if len(movie_list) == 0: print("There are no movies in the list.\n") return else: i = 1 for row in movie_list: print(str(i) + ". " + row[0] + " (" + str(row[1]) + ")") i += 1...
Modify the Assignment program from Module 1 to read a user's first and last name read...
Modify the Assignment program from Module 1 to read a user's first and last name read three integer scores, calculate the total and average determine the letter grade based on the following criteria - Average 90-100 grade is A, 80-89.99 grade is B, 70-79.99 grade is C, all others F (use a nested if) Output formatted results consisting of the full name, the three scores, the total, average (to 2 decimal places), and the letter grade go to step 1...
Module 11 Written Assignment-Comprehensive Final (Nursing 1) Your written assignment for this module should be a...
Module 11 Written Assignment-Comprehensive Final (Nursing 1) Your written assignment for this module should be a 1-2 page paper (not including title page and reference page) that describes the following: 1. What did you learn from this course that you did not already know? 2. How will you apply what you learned to your patient care?
Need to create Mortgage Calculator Program In C++ Modify your mortgage to include two functions. A...
Need to create Mortgage Calculator Program In C++ Modify your mortgage to include two functions. A function to get principal, rate, and term. A function to calculate monthly payment. Test your program by getting the data from the user by using the first function and calculate monthly payment by calling the other function. Add version control and write proper comments with a few blank lines & indentations in order to improve your programming style.
C++ Assignment 1) Write a C++ program specified below: a) Include a class called Movie. Include...
C++ Assignment 1) Write a C++ program specified below: a) Include a class called Movie. Include the following attributes with appropriate types: i. Title ii. Director iii. Release Year iv. Rating (“G”, “PG”, “PG-13”, etc) - Write code that instantiates a movie object using value semantics as text: - Write code that instantiates a movie object using reference semantics: - Write the print_movie method code: - Write Constructor code: - Write Entire Movie class declaration
Complete the following Module 2 Written Homework Assignment for this module by the stated due date...
Complete the following Module 2 Written Homework Assignment for this module by the stated due date on the Schedule. Please submit in the Module 2 Written Homework Assignment folder as a .doc, .docx, .pdf or .rtf file. Instructions Complete the following questions in the form of short essays. Each question is worth 6 points. Be sure to cite your references as needed. Type all responses following each question on this assignment page and submit to the folder. All-you-can-eat restaurants allow...
modify this program to either simulate a teacher or used car salesperson. #include <iostream> #include <string>...
modify this program to either simulate a teacher or used car salesperson. #include <iostream> #include <string> using namespace std; int Menu(string a, string b, string c) { int choice =-1; cout<<" 1)"<<a<<endl; cout<<" 2)"<<b<<endl; cout<<" 3)"<<c<<endl; cout<<" 4) I don't want to talk to you!!"<<endl; cin>>choice; return choice; } int Money(int x) { int c=-1; cout<<"\n Are you that materialistic? \n"; c = Menu(" No.", " Yes.", " Can we talk about something else?"); if(c == 1|| c ==2 )...
Modify the program to double each number in the vector. #include <iostream> #include <vector> using namespace...
Modify the program to double each number in the vector. #include <iostream> #include <vector> using namespace std; int main() { const int N=8; vector<int> nums(N); // User numbers int i=0; // Loop index cout << "\nEnter " << N << " numbers...\n"; for (i = 0; i < N; ++i) { cout << i+1 << ": "; cin >> nums.at(i); } // Convert negatives to 0 for (i = 0; i < N; ++i) { if (nums.at(i) < 0) {...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT