Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct Record
  6. {
  7. string title;
  8. string artist;
  9. int year;
  10. };
  11.  
  12. void displayRecord(const Record &r)
  13. {
  14. cout << r.title << " - " << r.artist << " (" << r.year << ")"<< endl;
  15. }
  16.  
  17. int main()
  18. {
  19. int recordamount;
  20. Record records[recordamount];
  21.  
  22. cout << "How many records do you wish to input? (Between 0 and 100)" << endl;
  23.  
  24. cin >> recordamount;
  25.  
  26. if (recordamount > 0 && recordamount < 100)
  27. {
  28. for (int i = 0; i < recordamount; i++)
  29. {
  30. cout << "Enter the title of the record:";
  31. getline(cin, records[i].title);
  32. cout << "Enter the artist of the record:";
  33. getline(cin, records[i].artist);
  34. cout << "Enter the year of the record:";
  35. getline(cin, records[i].year);
  36. }
  37. for (int i = 0; i < recordamount; i++)
  38. {
  39. displayRecord(records[i]);
  40. cout << endl;
  41. }
  42. }
  43.  
  44. else
  45. {
  46. cout << "You did not enter a valid number." << endl;
  47. }
  48.  
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement