Advertisement
YomoMan

Untitled

Jun 2nd, 2020
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <list>
  4.  
  5. using namespace std;
  6.  
  7. struct VideoLibrary {
  8.     string title;
  9.     unsigned int cost;
  10.     string producer;
  11. };
  12.  
  13. int main() {
  14.     char choice;
  15.     list<VideoLibrary> movies;
  16.     VideoLibrary movie;
  17.     unsigned int total_cost = 0;
  18.     do {
  19.         cout << "Enter title: ";
  20.         getline(cin, movie.title);
  21.         cout << "Enter cost: ";
  22.         cin >> movie.cost;
  23.         total_cost += movie.cost;
  24.         cout << "Enter producer name: ";
  25.         cin.ignore(1);
  26.         getline(cin, movie.producer);
  27.        
  28.  
  29.         movies.push_back(movie);
  30.         cout << "Add one more movie? (y/n): ";
  31.         cin >> choice;
  32.         cin.ignore(1);
  33.     } while (choice == 'y');
  34.     cout << "\n\n";
  35.  
  36.     cout << "Movies with cost lower than mean:" << endl;
  37.     for(auto it : movies) {
  38.         if (it.cost < (total_cost / movies.size())) {
  39.             cout << it.producer << " - " << it.title;
  40.             cout << " (" << it.cost << ")" << endl;
  41.         }
  42.     }
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement