Question: The Problem Statement You and your roommate are combining your DVD collections. What you'd like to do is see which DVD's you have duplicate copies

The Problem Statement

You and your roommate are combining your DVD collections. What you'd like to do is see which DVD's you have duplicate copies of, and then sell the extra copies on eBay, splitting the proceeds equally. To automate the process of determining how much money you expect to make, you decide to write a computer program.

Program Setup

A scaffold of the solution has been created for you:

dvd-scaffold.cThe Problem Statement You and your roommate are combining your DVD collections.What you'd like to do is see which DVD's you have duplicate

Do not modify the code that is already present. Instead, fill in the getProfit function marked like this: /*** ... ***/

This function takes in two arrays of DVDs (representing your roommates' DVDs and your DVDs, respectively), the lengths of both arrays, and returns the sum of the sale prices of all the DVDs in both collections with the identical titles. If both of you share a DVD with the same title but different sale prices (the 7th edition always costs more than the 6th), assume that you'll sell the more expensive copy and keep the cheaper one, in an effort to maximize your return.

Function Prototype

You must use this prototype to receive credit for the assignment.

// Pre-condition: list1 is an array of length len1, list2 is an array

// of length len2. No title appears in either list more

// than once.

// Post-condition: Returns the sum of the sale prices of the common

// DVDs in both lists. Two DVDs are considered the

// same if their titles are identical.

double getProfit(DVD* list1, int len1, DVD* list2, int len2);

DVD-SCAFFOLD.C

#include  #include  typedef struct { char title[100]; int runTime; int idtag; double salePrice; } DVD; double getProfit(DVD* list1, int len1, DVD* list2, int len2) ; double max(double a, double b); DVD* get(FILE* ifp, int len); int main() { FILE* ifp = fopen("dvd.in", "r"); int numCases, loop; fscanf(ifp, "%d", &numCases); // Go through each case. for (loop=0; loop

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!