Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I. Use the diagrams shown to answer the questions A. Write the structure definit

ID: 3547566 • Letter: I

Question


I. Use the diagrams shown to answer the questions
A. Write the structure definitions based on the following diagrams. Use nested (struct within struct) structs where appropriate.



B. Using your structs for A, declare an array of Soundtrack structs that has 50 elements.



C. Assign the following values to the first 2 elements in the Soundtrack array:


Field Name Value Set 1 Value Set 2
First Miklos Elmer
Last Rozsa Bernstein
Catalog Number 72197 VCL 8124
Recording Year 1959 1963
Release Year 1996 2004
Name Rhino Varese Sarabande
Film Ben-Hur The Great Escape


D. Create a function to display all the data in t
he Soundtrack array.


E. Write a function call to the function

you created.

Use the diagrams shown to answer the questions Write the structure definitions based on the following diagrams. Use nested (struct within struct) structs where appropriate. Using your structs for A, declare an array of Soundtrack structs that has 50 elements. Assign the following values to the first 2 elements in the Soundtrack array: Field Name Value Set 1 Value Set 2 First Miklos Elmer Last Rozsa Bernstein Catalog Number 72197 VCL 8124 Recording Year 1959 1963 Release Year 1996 2004 Name Rhino Varese Sarabande Film Ben-Hur The Great Escape Create a function to display all the data in t Write a function call to the function

Explanation / Answer

#include <iostream> #include <string> #include <sstream> using namespace std; //*** part A starts ***// struct DateData{ int RecordYear; int ReleaseYear; };
struct Composer{ string First; string Last; };
struct Label{ string CatalogNumber; string Name; DateData date; };
struct Soundtrack { Composer comp; Label labl; string film; };//*** part A ends ***//
//*** part D starts ***// void displaySoundtracks (Soundtrack s_t) { cout << "First Name : " << s_t.comp.First << " "; cout << "Last Name : " << s_t.comp.Last << " "; cout << "Catalog Number : " << s_t.labl.CatalogNumber << " "; cout << "Recording Year : " << s_t.labl.date.RecordYear << " "; cout << "Release Year : " << s_t.labl.date.ReleaseYear << " "; cout << "Name : " << s_t.labl.Name << " ";
  1.   cout << "Film : " << s_t.film << " ";
  2. }//*** part D ends ***//
  3. int main ()
  4. {
  5. string mystr;
  6. Soundtrack s_t[50]; //***part B***//
  7.   //*** part C starts ***//
  8. s_t[0].film="Ben-Hur";
  9. s_t[1].film="The Great Escape";
  10. s_t[0].comp.First="Miklos";
  11. s_t[0].comp.Last="Rozsa";
  12. s_t[1].comp.First="Elmer";
  13. s_t[1].comp.Last="Bernstein";
  14. s_t[0].labl.CatalogNumber="72197";
  15. s_t[0].labl.Name="Rhino";
  16. s_t[0].labl.date.RecordYear=1959;
  17. s_t[0].labl.date.ReleaseYear=1996;
  18. s_t[1].labl.CatalogNumber="VCL 8124";
  19. s_t[1].labl.Name="Varese Sarabande";
  20. s_t[1].labl.date.RecordYear=1963;
  21. s_t[1].labl.date.ReleaseYear=2004;//*** part C ends ***//
  22. displaySoundtracks(s_t[0]);//*** part E starts ***//
  23.   cout << " ";
  24. displaySoundtracks(s_t[1]);//*** part E ends ***//
  25.   int pappu;
  26.   cin >> pappu;
  27.   return 0;
  28. }
  cout << "Film : " << s_t.film << " "; }//*** part D ends ***// int main () { string mystr; Soundtrack s_t[50]; //***part B***//   //*** part C starts ***// s_t[0].film="Ben-Hur"; s_t[1].film="The Great Escape"; s_t[0].comp.First="Miklos"; s_t[0].comp.Last="Rozsa"; s_t[1].comp.First="Elmer"; s_t[1].comp.Last="Bernstein"; s_t[0].labl.CatalogNumber="72197"; s_t[0].labl.Name="Rhino"; s_t[0].labl.date.RecordYear=1959; s_t[0].labl.date.ReleaseYear=1996; s_t[1].labl.CatalogNumber="VCL 8124"; s_t[1].labl.Name="Varese Sarabande"; s_t[1].labl.date.RecordYear=1963; s_t[1].labl.date.ReleaseYear=2004;//*** part C ends ***// displaySoundtracks(s_t[0]);//*** part E starts ***//   cout << " "; displaySoundtracks(s_t[1]);//*** part E ends ***//   int pappu;   cin >> pappu;   return 0; }