Question

In C++ write a program; Your goal is to create a structure to store information about...

In C++ write a program;

Your goal is to create a structure to store information about a movie.

Your program should have the following:

-The name of the program should be Assignment8.

-3 comment lines (description of the program, author, and date)

-Write a program that uses a structure named MovieData to store the following information about a movie: (3 points)

Title, Director, Year released, Running time (in minutes)

The program should create 2 MovieData variables, store values in their members, and pass each one, in turn, to a function that displays the information about the movie in a clearly formatted manner. (7 points)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/******************************Assignment8.cpp***********************/

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

const int SIZE = 50;
struct MovieData
{
   char title[SIZE];
   char director[SIZE];
   int year;
   int runningTime;
};
void getMovie(MovieData&);
void displayMovie(MovieData);
int main()
{
   MovieData movie1, movie2;

   getMovie(movie1);
   getMovie(movie2);
   displayMovie(movie1);
   displayMovie(movie2);
   return 0;
}

void getMovie(MovieData &movie1)
{
  
   //Get movie title
   cout << "Enter the title of the movie: ";
   cin.ignore();
   cin.getline(movie1.title, SIZE);

   //Get director's name
   cout << "Enter the Director name: ";
   cin.getline(movie1.director, SIZE);

   //Get the release year
   cout << "Enter the released year: ";
   cin >> movie1.year;

   //Get the movie runtime in minutes
   cout << "Enter runtime of movie: ";
   cin >> movie1.runningTime;

}

void displayMovie(MovieData movie1)
{
  
   //Display the movie information
   cout << "Movie Title: " << movie1.title << endl;
   cout << "Director's Name: " << movie1.director << endl;
   cout << "Release Year: " << movie1.year << endl;
   cout << "Movie Runtime in minutes: " << movie1.runningTime << endl;


}

/************************output************************/

Enter the title of the movie: Captain America: The First Avenger
Enter the Director name: Joe Johnston
Enter the released year: 2011
Enter runtime of movie: 142
Enter the title of the movie: Avengers: Endgame
Enter the Director name: Anthony Russo
Enter the released year: 2019
Enter runtime of movie: 182
Movie Title: aptain America: The First Avenger
Director's Name: Joe Johnston
Release Year: 2011
Movie Runtime in minutes: 142
Movie Title: Avengers: Endgame
Director's Name: Anthony Russo
Release Year: 2019
Movie Runtime in minutes: 182

Please let me know if you have any doubt or modify the answer, Thanks :)

Add a comment
Know the answer?
Add Answer to:
In C++ write a program; Your goal is to create a structure to store information about...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++Write a program that uses a class name MovieData to store the following information about a...

    C++Write a program that uses a class name MovieData to store the following information about a movie: create a class not a strcuture please. Title Director Year release Running time Inclue a constructor that allows all four of these memberdata values to be sprcified at the time a MovieData variable is created The program should create two MovieData variable. Do not use user input. Have a stand alone function that displays the information about the movie in a clearly formatted...

  • 1.C++ Write a program that uses a structure named MovieData to store the following information about...

    1.C++ Write a program that uses a structure named MovieData to store the following information about a movie: title, director, year released, and running time (in minutes). Include a constructor that allows all four of these member data values to be specified at the time a MovieData variable is created. Your program should do the followings: A. creates two MovieData variables (namely, movie1 and movie2) B. creates two pointers to the structure MovieData (namely, movie1Ptr and movie2Ptr) and initializes them...

  • write a C++ program that uses a class named Movie to store the following information about...

    write a C++ program that uses a class named Movie to store the following information about a movie: - Title - Director - Year Released - Running time (in minutes) + print() : Function that will print the information for this movie in a nice format Include a constructor that allows all four of these member data values to be specified at the time a Movie variable is created. The program should create four Movie variables and call its print()...

  • SC 111 - BMCC Exam Student Name: Type # 4 - 20 Points write a program...

    SC 111 - BMCC Exam Student Name: Type # 4 - 20 Points write a program that uses a structure named Student to store the following information about a Student: Name ID GPA Address The program should create three Student instances, store values, and pass all of them to a function that displays the information about the Student in a clearly formatted manner. The program also uses another function to calculate and display the average GPA of all three Students.

  • In C++ write a program: Your goal is to ask record the sales for 5 different...

    In C++ write a program: Your goal is to ask record the sales for 5 different types of salsa, the total sales, and the names of the highest and lowest selling products. Your program should have the following:  The name of the program should be Assignment7.  3 comment lines (description of the program, author, and date).  Create a string array that stores five different types of salsas: mild, medium, sweet, hot, and zesty. The salsa names should...

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • Structures in C++ :- 2. Write a program that declares a structure to store the distance...

    Structures in C++ :- 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then display the record of the winner. 3. Write a program that declares a structure to store income, tax rate and tax of a person. The program defines an array of structure to store the records of five person. It inputs income...

  • Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director,...

    Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...

  • c++ if you answer the question please write it line by line and not in paragrapth...

    c++ if you answer the question please write it line by line and not in paragrapth form. Write a C++ program that uses a structure named Movie to store the following. a. Title b. Director c. Year Released d. Running time (in minutes) e. Cost of production f. Revenue (first year). Create an array of type Movie of size 3. In your main program should then have in a loop (3 times) called a function called getData() and the purpose...

  • Write this program in C language Ensure the program output is exactly as described, and that...

    Write this program in C language Ensure the program output is exactly as described, and that the whitespace of your source code is well formatted. Utilise good naming practices when declaring variables. EXERCISE NAME: Recursive Movie In the history of Jurassic Park movies the following movies were released: Movie's Name: Jurassic Park The Lost World: Jurassic Park Jurassic Park III Jurassic World Year of Release: Rotten Tomatoes: 1993 93% 1997 51% 2001 50% 2015 72% Implement a structure type named...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT