Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++: Display sorted favorite movies. Use a linked list to store your favorite movies. Store the movie objects into a linked list, display the movie

C++:

Display sorted favorite movies.

Use a linked list to store your favorite movies.

Store the movie objects into a linked list, display the movie information by sorting with the title, viewed year, and rating.

You may need three more functions to display the sorted movie information by passing the pointer of the first movie object in the linked list:

image text in transcribedSo far, I have gotten this far in my code:

-----------------------------------------------

#include

#include

#include

using namespace std;

struct movie

{

string title;

int viewed_year;

int rating;

movie* next;

};

void list_movie(const movie* head)

{

cout

cout

int i = 1;

for (const movie* p = head; p; p = p->next)

{

cout

cout title;

cout viewed_year;

cout rating

}

}

int main()

{

movie* firstmovie = 0;

string title1, title2, title3;//3 Strings to store names of the movies

int viewed_year1, viewed_year2, viewed_year3; //3 ints's to store viewed year of the movies

int rating1, rating2, rating3; //3 ints's to store rating of the movies

cout

getline(std::cin, title1);

cout

cin >> viewed_year1;

cout

cin >> rating1;

cin.get();

cout

getline(std::cin, title2);

cout

cin >> viewed_year2;

cout

cin >> rating2;

cin.get();

cout

getline(std::cin, title3);

cout

cin >> viewed_year3;

cout

cin >> rating3;

//3 movie objects to store the movies

movie a = { title1, viewed_year1, rating1 };

movie b = { title2, viewed_year2, rating2 };

movie c = { title3, viewed_year3, rating3 };

a.next = firstmovie;

firstmovie = &a;

b.next = firstmovie;

firstmovie = &b;

c.next = firstmovie;

firstmovie = &c;

//Function call to print the movies

list_movie(firstmovie);

}

-----------------------------------------------

Any help is greatly appreciated, thank you.

void arrange_ by title(Movie) void arrange_by rating(Movie* void arrange_by viewed(Movie* - Sample output, Please enter the title of the movie1(within 30-character):Now You See Me Please enter the year you viewed Now You See Me [like 2017]:2014 Please your rating for Now You See Me [1, 2, 3, 4, 5]:4 Please enter the title of the movie2 (within 30-character):X-Men: First Class Please enter the year you viewed X-Men: First Class [like 20171:2011 Please your rating for X-Men: First Class [1, 2, 3, 4, 5]:3 Please enter the title of the movie3(within 30-character):Hidden Figures Please enter the year you viewed Hidden Figures [like 2017]:2016 Please your rating for Hidden Figures [1, 2, 3, 4, 5]:5 *Display Movies info sorted by titles** Movie Title Viewed Rating 5 3 Viewed Rating 3 5 Viewed Rating 1 Hidden Figures 2 Now You See Me 2016 2014 2011 Display Movies info sorted by rating* X-Men: First Class Movie Title 1 X-Men: First Class 2 Now You See Me 3 Hidden Figures 2011 2014 2016 *Display Movies info sorted by viewed years** Movie Title 1 X-Men: First Class 2 Now You See Me 3 Hidden Figures 2011 2014 2016 5 Program ended with exit code:e

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Define Management by exception

Answered: 1 week ago

Question

Explain the importance of staffing in business organisations

Answered: 1 week ago

Question

What are the types of forms of communication ?

Answered: 1 week ago

Question

Explain the process of MBO

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago