Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ assignment. I am having the following error codes and need to complete below code for turn-in. Code is below error messages. Severity Code Description

C++ assignment. I am having the following error codes and need to complete below code for turn-in. Code is below error messages.

Severity Code Description Project File Line Suppression State

Error (active) E0147 declaration is incompatible with " allMedia" (declared at line 188) MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 31

Error (active) E0098 an array may not have elements of this type MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 128

Error (active) E0020 identifier "String" is undefined MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 138

Error (active) E0065 expected a ';' MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 138

Error (active) E0169 expected a declaration MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 162

Error (active) E0077 this declaration has no storage class or type specifier MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 188

Error (active) E0020 identifier "med" is undefined MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 188

Error (active) E0169 expected a declaration MidTermProject c:\Users\Michael\source epos\MidTermProject\MidTermProject\Source.cpp 189

Error C2087 'b': missing subscript MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 128

Error C2234 'b': arrays of references are illegal MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 128

Error C2440 '=': cannot convert from 'std::string' to 'std::string *' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 130

Error C2440 '=': cannot convert from 'std::string' to 'std::string *' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 131

Error C2440 '=': cannot convert from 'std::string' to 'std::string *' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 132

Error C2440 '=': cannot convert from 'std::string' to 'std::string *' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 133

Error C2440 '=': cannot convert from 'std::string' to 'std::string *' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 134

Error C2440 '=': cannot convert from 'std::string' to 'std::string *' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 135

Error C2065 'String': undeclared identifier MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 138

Error C2146 syntax error: missing ')' before identifier 'a' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 138

Error C2143 syntax error: missing ';' before '{' MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 138

Error C2447 '{': missing function header (old-style formal list?) MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 138

Error C1004 unexpected end-of-file found MidTermProject c:\users\michael\source epos\midtermproject\midtermproject\source.cpp 212

Here is my code.

#include

#include

using namespace std;

int index = 0; //Variable to show how many Media Items are entered.

struct Media { // Media struct

string title;

string starring;

string format;

string genre;

string yearProduced;

string comments;

};

int displayMenu();

Media getMedia();

void showMedia(Media);

void allMedia(Media[]);

void sortMedia(Media[]);

void findMedia(Media[], int);

int main()

{

Media med[1000]; // Declare array of Media struct

while (true)

{

int choice = displayMenu();

switch (choice)

{

case 1:

med[index] = getMedia();

index++;

break;

case 2:

allMedia(med);

break;

case 3:

sortMedia(med);

break;

case 4:

findMedia(med, index);

break;

case 5:

cout << "You have selected to exit the program. Thank you." << endl;

return 0;

break;

default:

cout << "That is not a valid choice. Please try again." << endl;

}

cout << endl;

}

system("pause");

return 0;

}

int displayMenu() //Display menu to user

{

cout << "The Greely Family Media Library" << endl;

cout << endl;

cout << "Please select from the below menu." << endl;

cout << endl;

cout << "1. Enter New Media Item." << endl;

cout << "2. Display all Media Items." << endl;

cout << "3. Sort all Media Items." << endl;

cout << "4. Display a particular Media Item." << endl;

cout << "5. Exit the program." << endl;

cout << endl;

int choice; //User selects what they want to do.

cout << "Enter choice: ";

cin >> choice;

cin.ignore();

cout << endl;

return choice;

}

Media getMedia()

{

Media a;

cout << "Enter Title: ";

getline(cin, a.title);

cout << endl;

cout << "If Media Item is a music CD, enter the singer or group. If a PC Game, enter N/A. " << endl;

cout << "Enter Starring: ";

getline(cin, a.starring);

cout << endl;

cout << "Format can be DVD, VHS, CD, Blue-Ray or PC Game." << endl;

cout << "Enter format: ";

getline(cin, a.format);

cout << endl;

cout << "Genre can be Main theme of item followed by TV Show, Movie, Music or PC Game." << endl ;

cout << "Example of Genre: Childen's Comedy TV Show " << endl;

cout << "Enter genre: ";

getline(cin, a.genre);

cout << "Enter Year Produced:";

getline(cin, a.yearProduced);

cout << endl;

cout << "Comments are exactly that. A way to refresh your memory what the Media Item is about." << endl;

cout << "Example, Daktari was a show that I watched on Sundays when growing up. " << endl;

cout << endl;

cout << "Enter Comments: ";

getline(cin, a.comments);

return a;

}

void copyTo2DArray(Media a[], string &b[][], int n) {

for (int i = 0; i

b[i][0] = a[i].title;

b[i][1] = a[i].starring;

b[i][2] = a[i].format;

b[i][3] = a[i].genre;

b[i][4] = a[i].yearProduced;

b[i][5] = a[i].comments;

}

void showMediaMod(String a[][6], int n) {

cout << setw(10) << left << "Title";

cout << setw(10) << "Starring";

cout << setw(10) << "Format";

cout << setw(10) << "Genre";

cout << setw(10) << "Year Produced";

cout << setw(10) << "Comments" << endl;

for (int i = 0; i < n; i++) {

cout << setw(10) << left << a[n][0];

cout << setw(10) << a[n][1];

cout << setw(10) << a[n][2];

cout << setw(10) << a[n][3];

cout << setw(10) << a[n][4];

cout << setw(10) << a[n][5] << endl;

}

void allMedia(Media med[])

{

for (int i = 0; i < index; i++)

{

showMedia(med[i]);

cout << endl;

}

}

void sortMedia(Media *med) //Sort by format and then title

{

for (int i = 0; i < index; i++)

{

for (int j = 0; j < index; j++)

{

if (med[i].format == med[j].format) //Checking to see if formats are equal

{

if (med[i].title < med[j].title) //Formats are equal then compare titles

{

Media t = med[i]; //Swapping addresses of elements

med[i] = med[j];

med[j] = t;

}

}

else if (med[i].format < med[j].format) //Checking with formats

{

Media t = med[i];

med[i] = med[j];

med[j] = t;

}

}

}

cout << "After sorting by Format and Title. " << endl; //Display Lists

allMedia(med);

}

void findMedia(Media med[], int size) //Ask User to enter a title.

{

string title;

cout << "Enter Title: ";

cin >> title;

for (int i = 0; i < size; i++)

{

if (med[i].title == title)

{

showMedia(med[i]);

return;

}

}

cout << "This title cannot be found. It appears that you do not have this in your selection." << endl;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Show that P{Ta Answered: 1 week ago

Answered: 1 week ago

Question

What was the positive value of Max Weber's model of "bureaucracy?"

Answered: 1 week ago