V.18 Write a program that emulates a stack using a linked list. Implement the menu using an enumerated type. Write funct
Posted: Fri Jul 08, 2022 6:15 am
Example Screen Input/Output should be formatted as follows (You do not need to format your data into two columns as shown on the next page) STACK MENU: 1-Add a person (PUSH) 2-Remove a person (POP) 3-Is the stack empty? (ISEMPTY) 4-Who is on top? (PEEK) 5-How many people are there? (SIZE) 0-to Exit Enter a command? 1 Who would you like to add? Enter Name: Joe Smith Enter Gender: M Enter Age: 32 <redisplay menu> Enter a command? 1 Who would you like to add? Enter Name: Grace Hopper Enter Gender: F 69 Enter Age: <redisplay menu> Enter a command? 4 Double Space (1 blank line) PEEKING at Name: Grace Hopper Gender: F Age: 69 <redisplay menu> Enter a command? 5 There are 2 people on the stack. <redisplay menu> Enter a command? 1 Who would you like to add? Enter Gender: F Enter Age: 52 <redisplay menu> Enter a command? 4 SEKING at Name: Ada Lovelace Gender: F Age: 52 <redisplay menu> Enter a command? 3. The stack is NOT empty. <redisplay menu> Enter a command? 2 POPPING Name: Ada Lovelace Gender: F Age: 52 <redisplay menu> Enter a command? 1 Who would you like to add? Enter Name: Charles Babbage Enter Gender: M Enter Age: 25
Enter a command? 4 PEEKING at Name: Charles Babbage Gender: M Age: 25 <redisplay menu> Enter a command? 5 There are 3 people on the stack. <redisplay menu> Enter a command? 2 POPPING Name: Charles Babbage Gender: M Age: 25 <redisplay menu> Enter a command? 5 There are 2 people on the stack. <redisplay menu> Enter a command? 4 PEEKING at Name: Grace Hopper Gender: F Age: 69 <redisplay menu> Enter a command? 2 POPPING Name: Grace Hopper Gender: F Age: 69 <redisplay menu> Enter a command? 5 There is one person on the stack. <redisplay menu> Enter a command? 3 The stack is NOT empty. <redisplay menu> Enter a command? 4 PEEKING at Name: Joe Smith Gender: M Age: 32 <redisplay menu> Enter a command? 2 POPPING Name: Gender: M Age: 32 Joe Smith <redisplay menu> Enter a command? 5 Nobody is on the stack! <redisplay menu> Enter a command? 2 Can't POP from an empty stack! <redisplay menu> Enter a command? 3 Yes, the stack is empty.
<redisplay menu> Enter a command? 4 There is nobody to PEEK at! <redisplay menu> Enter a command? -1 **** The number -1 is an invalid entry **** Please input a number between 0 and 5 <redisplay menu> Enter a command? 6 *** The number 6 is an invalid entry **** Please input a number between 0 and 5 <redisplay menu> Enter a command? abc **** Please input a number between 0 and 5 **** <redisplay menu> Enter a command? 0