Lexington High School Mathematics Math Dept. Front Page  | Student Links  | Family Links 
Introduction to C++, Kevin Kelly Kelly Front Page  | C++ Course Guide | C++ Assignments | C++ Info

Assignment 7: Compact discs

due Thursday 2/14



Warning about a limitation of apstring: An ordinary C++ input statement into an apstring variable stores only the first word of input. Often that may not be the behavior you want. To allow for input that includes spaces (such as a first name and a last name), use a getline statement as shown below.

Instead of:cin >> fullname;
Use:getline(cin, fullname);

The Assignment

Write a program that will ask the user for several pieces of information about their most favorite compact disc and about their least favorite compact disc. For each disc, the user should be asked for at least the following information: artist, title, number of tracks, and year.

Your program must include a definition of a structure called CD that is capable of storing the information listed above. The information must be stored in two variables of type CD, called mostfavcd and leastfavcd.

After all of the information has been input and stored, output the information from mostfavcd and leastfavcd back to the user.


Extensions

For 3 pts.: Output the information in a table, with the most favorite CD in one column and the least favorite CD in another column. Make sure the columns are properly aligned.

For 10 pts.: In addition to everything listed above, also include a nested structure that can store the names of individual band members. For example, mostfavcd.band.drums could contain the name "Ringo Starr".