Question

In: Computer Science

I am struggling with c++ and I could use some guidance getting through this project. Below...

I am struggling with c++ and I could use some guidance getting through this project. Below are my directions.

The objective of this project is to be able to incorporate structures in a program. The program will have the user enter the information for two movies (details below) and then display a list of recommended movies that have 4 or more stars.

1. You will need to create a structure named MovieInfo that contains the following information about a movie:

  • title (string) - title of the movie
  • release date (string)
  • mpaa rating (string) - G, PG13, PG, R, NC17
  • number of stars (double) - out of 5

2. The main program will create two MovieInfo variables, for example movie1 and movie2.

3. Write a function to prompt the user to enter the information for one movie (title, release date, mpaa rating and number of stars). This function should then return the movie information back to main. You should call this function twice, once for each of the MovieInfo variables in main.

Note: After you read the number of stars, you will need to use cin.get() or cin.ignore() to get rid of the end of line character prior to the next call to getline in your program

cout << "Enter the number of stars the movie received : ";
cin >> movie.numberOfStars;
cin.get();

4. Write a function to display a list of movie recommendations that contains only the movies with 4 or more stars. The list of recommendations should include:

  • a title - Movie Recommendations
  • movie name
  • number of stars (formatted so you have 1 place after the decimal point)

You will need to use an if .. else if statement to display either both movies, one movie, or a message that you have no recommendations.

5. Your project must contain documentation (comments)

  • name at the top
  • brief explanation of the program at the top
  • comments prior to each function explaining the purpose of the function

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

This is the code I have started and am stuck. Am I on the right track?

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

struct MovieInfo
{

   string title- title of the movie ; //
   string release date ; //
   string mpaa rating - G, PG13, PG, R, NC17 ; //
   double number of stars (1 out of 5) ; //

};

int main()
{
   MovieInfo movie1 = {"title", "release date", "mpaa rating", "number of stars"};
   MovieInfo movie2 = {"title", "release date", "mpaa rating", "number of stars"};
}

void movieTitle (title)
  
   cout << "Enter the title of the Movie : " << endl;
   cin >> title >> endl;
   cin.get();
  
  
}

Solutions

Expert Solution

Please let me know if you need more information:-

=====================================

#include <iostream>

#include <iomanip>

#include <list>

#include <iterator>

using namespace std;

/*

1. You will need to create a structure named MovieInfo that contains the following information about a movie:

title (string) - title of the movie

release date (string)

mpaa rating (string) - G, PG13, PG, R, NC17

number of stars (double) - out of 5

*/

struct MovieInfo

{

string title; //- title of the movie

string releaseDate ; //

string mpaaRating; // rating - G, PG13, PG, R, NC17

double numberOfStars; // of stars (1 out of 5)

};

/*

3. Write a function to prompt the user to enter the information for one movie (title, release date, mpaa rating and number of stars). This function should then return the movie information back to main. You should call this function twice, once for each of the MovieInfo variables in main.

Note: After you read the number of stars, you will need to use cin.get() or cin.ignore() to get rid of the end of line character prior to the next call to getline in your program

cout << "Enter the number of stars the movie received : ";

cin >> movie.numberOfStars;

cin.get();

*/

MovieInfo promptForMovieInformationAndReturn(){

MovieInfo movie;

cout<<"Enter the title of movie : ";

getline (cin,movie.title);

cout<<"Enter the release date of movie : ";

getline (cin,movie.releaseDate);

cout<<"Enter the mpaa rating of movie : ";

getline (cin,movie.mpaaRating);

cout << "Enter the number of stars the movie received : ";

cin >> movie.numberOfStars;

cin.get();

cout<<endl;

return movie;

}



/*

4. Write a function to display a list of movie recommendations that contains only the movies with 4 or more stars. The list of recommendations should include:

a title - Movie Recommendations

movie name

number of stars (formatted so you have 1 place after the decimal point)

You will need to use an if .. else if statement to display either both movies, one movie, or a message that you have no recommendations.

*/

void displayListOfMovieRecommendations(list<MovieInfo> movies){

list <MovieInfo> :: iterator it;

cout<<setw(16)<<left<<"*******************************"<<endl;

cout<<setw(16)<<left<<" Movie Recommendations "<<endl;

cout<<setw(16)<<left<<"*******************************"<<endl;

for(it = movies.begin(); it != movies.end(); ++it) {

if(it->numberOfStars >= 4 ){

cout <<setw(16)<<left<< it->title<<setw(16)<<left<<setprecision(2)<< it-> numberOfStars <<endl;

}

}

}

int main() {

/*

2. The main program will create two MovieInfo variables, for example movie1 and movie2.

*/

MovieInfo movie1;

MovieInfo movie2;

movie1 = promptForMovieInformationAndReturn();

movie2 = promptForMovieInformationAndReturn();

list <MovieInfo> movies;

movies.push_back(movie1);

movies.push_back(movie2);

displayListOfMovieRecommendations(movies);

}

==

==


==============================

Enter the title of movie : Avengers
Enter the release date of movie : 03/05/2018
Enter the mpaa rating of movie : NC17
Enter the number of stars the movie received : 4.8

Enter the title of movie : 300 Men
Enter the release date of movie : 06/07/2016
Enter the mpaa rating of movie : PG13
Enter the number of stars the movie received : 4.25

*******************************
Movie Recommendations
*******************************
Avengers 4.8
300 Men 4.2

==

===

Thanks


Related Solutions

Here is a project I am currently working on and I could use some feedback on...
Here is a project I am currently working on and I could use some feedback on how to get started. I calculated the general probabilities for the first two columns of each spreadsheet (successes / total outcomes). I don't want to move forward until I know I'm on the right track but I'm concerned that I've oversimplified the question being asked. I'm also using Excel and am having a hard time finding an appropriate formula for conditional probability. My book...
For some reason I am having a hard time getting this program to compile properly. Could...
For some reason I am having a hard time getting this program to compile properly. Could you help me debug it? Write the prototypes and functions to overload the given operators in the code //main.cpp //This program shows how to use the class rectangleType. #include <iostream> #include "rectangleType.h" using namespace std; int main() {     rectangleType rectangle1(23, 45);                     //Line 1     rectangleType rectangle2(12, 10);                     //Line 2     rectangleType rectangle3;                             //Line 3     rectangleType rectangle4;                             //Line 4     cout << "Line...
Syntax error in C. I am not familiar with C at all and I keep getting...
Syntax error in C. I am not familiar with C at all and I keep getting this one error "c error expected identifier or '(' before } token" Please show me where I made the error. The error is said to be on the very last line, so the very last bracket #include #include #include #include   int main(int argc, char*_argv[]) {     int input;     if (argc < 2)     {         input = promptUserInput();     }     else     {         input = (int)strtol(_argv[1],NULL, 10);     }     printResult(input);...
Exam prep question I am struggling with. Could anyone give me a solution with steps? Thank...
Exam prep question I am struggling with. Could anyone give me a solution with steps? Thank you! You are an executive at WX Resorts and you have executive stock options as part of your compensation. You hold 1,000 options that expire six months from today at a strike price of 50 but that can be exercised early. WX is trading at $55 and just announced a $1 dividend per share that will be paid four months from today to stockholders...
Hi, I am struggling to understand this worksheet my professor gave us for practice. Could someone...
Hi, I am struggling to understand this worksheet my professor gave us for practice. Could someone make any sense of this? The scenario: Sodium is found largely in the extracellular compartment with concentrations between 130-145 mM with intracellular sodium concentrations between 3.5-5mM. This chemical difference gives sodium a large concentration gradient, which when permitted (by opening of a channel or through facilitated transport) will move down its concentration gradient to enter the cell. Sodium also has a favorable electrical gradient;...
I am comfortable with structures that contains one item per variable. But i am struggling to...
I am comfortable with structures that contains one item per variable. But i am struggling to manage structure that contains multiple items in one variable (within a matrix). it's in C language. for example this structure :    struct resume{ char *name; char *job; char school*; int counter_resume; }resume; i want to create functions that are able to dynamically allocate memory so it can add multiple persons resume without knowing how many they are going to be in the beginning....
I am very lost on this. If there is an Excel formula I could use, that...
I am very lost on this. If there is an Excel formula I could use, that would help tremendously. Thank you... Create confidence intervals related to the interval and ratio-level data you collected. 1. What is the best estimate of the population mean 2. Develop a 95% confidence interval for the population mean. Develop a 90% confidence interval for the population mean. Develop a 98% confidence interval for the population mean. 3. Interpret the confidence interval. Create an individual Excel...
PLEASE answer number 2 (worksheet) I am really struggling with it. Below is the unadjusted trial...
PLEASE answer number 2 (worksheet) I am really struggling with it. Below is the unadjusted trial balance for Walton Anvils as of December 31, 2016, and the data for the adjustments. There is also an Excel Template for this problem that you may download and use (or you may use your own). Walton Anvils Unadjusted Trial Balance December 31, 2016 Balance Account Title Debt Credit Cash $    16,900.00 Accounts Receivable               17,500 Prepaid Rent                 2,500 Office Supplies                 1,900...
Develop the following code for quiz (i am getting some errors)in python in such a manner...
Develop the following code for quiz (i am getting some errors)in python in such a manner that it shoulde be having extra 3 attempts(for wrong answrs) for all questions if the user entered wrong answer · for ex: If the user entered correct answer for first question #then 3 attempts will be carried to next questions. If the user entered 3 times wrong answer in 1st question itself means it sholud display as no more attempts and you got o...
Hello, I am struggling to understand some of my accounting homework. Question 01 ) Tulsa Company...
Hello, I am struggling to understand some of my accounting homework. Question 01 ) Tulsa Company is considering investing in new bottling equipment and has two options: Option A has a lower initial cost but would require a significant expenditure to rebuild the machine after four years; Option B has higher maintenance costs, but also has a higher salvage value at the end of its useful life. Tulsa’s cost of capital is 11 percent. The following estimates of the cash...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT