Define a struct which has exactly 5 variables that for one


Cr-z-a.te a program that uses a linked list to keep track of the US Presidents.

We have a data the which contains the last name, followed by "other" names ()leach US President, in order. along with the date each took office and the date each left office. By "other" names is meant first or first plus middleks).

Define a struct which has exactly 5 variables that, for one person, will hold the last name, the "other" names. the-year-took-office. the-yew-left-office, and a pointer. The pointer will be used to point to the next set of data. for the next person.

_Arrange r our links so that you have first George Washington, then John Adams. then Thomas Jefferson,etc.

Make sure you terminate the linked list properly.

In your program. read all this data from the file (use a loop) and store it in a linked list. The pointer stored with each President should point to the next President's struct variable.

Then have your program print out these words "The United States Presidents, and the number of years they held office." Move the cursor down to the next line.

Then use the linked-list pointers to step through the list (using a loop) and print out the "other" names (containing whatever spaces they had originally) followed by a space followed by the last name of each person and after the person's name the number of years they were in office (this is a value calculated in your program). So the output has one President per line. Use setw() so that the number-of-years-in¬office are all lined up in a column, right-aligned. For the one still in office print after the name, "Currently in office."

Look at the data file before you start to plan your program. You may test specifically for Van Buren, the only president with a space in his last name, but otherwise do not tailor your program for specific data entries. Make the program general to handle all the data. Do not make any changes in the data tile.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Define a struct which has exactly 5 variables that for one
Reference No:- TGS0656043

Now Priced at $40 (50% Discount)

Recommended (91%)

Rated (4.3/5)