Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

L9A - Implementing a Queue F19 Lab #9A Implementing a Stack CS1B 1 of 4 Name1: _____________________________ Name2: _____________________________ Class Day / Time: _____________________________ Due...

1 answer below »
L9A - Implementing a Queue F19
Lab    #9A         Implementing    a    Stack     CS1B    
     1    of    4    
Name1: _____________________________
Name2: _____________________________
Class Day / Time: _____________________________
Due Date: _____________________________
Lab #9A – Implementing a Queue
Write    a    program    that    implements    a    queue    using    a    linked-list.
Write    functions    to    implement    each    of    the    following    tasks.    
- Enqueue    
- Dequeue    
- IsEmpty    
- Front    
- Size    
- Clear    Queue    
Provide    a    menu    for    the    user    to    choose    one    of    these    6    options    (e
or    check    the    input    to    ensure    it    
is    in    the    proper    range).    If    they    choose    enqueue    allow    them    to    enter    in    a    name,    gender,    and    age.        
If    they    choose    to    dequeue,    let    them    know    all    the    info    about    the    person    who    is    being    removed    
(if    the    list    is    empty,    let    them    know).            If    they    request    the    front,    show    them    whom    are    at    the    
front    of    the    list.        If    they    choose    size,    tell    them    how    many    people    are    in    the    list.        If    they    choose    
clear    queue    Ã     empty    the    list.        Validate    the    user    input.            
    
Turn in as a single PDF file (IN THIS ORDER)
1. Your header file.
2. a listing of main.cpp (conforming to style discussed in class)
3. a listing of your print heading function (should be in a separate file)
4. a listing of your functions (in at least 1 separate file)
5. screen I/O – pasted into a text file within eclipse and output
    
OUTPUT    MESSAGE    FORMAT        
Check    below    for    a    more    detailed    description    of    the    expected    input    and    output    
Invalid    command    inputs    
Out    of    range    e
or:    
****    The    number    -1    is    an    invalid    entry                                             ****    
****    Please    input    a    number    between    0    and    6            ****    
Character    input:    
****    Please    input    a    NUMBER    between    0    and    6    ****
Size    
For    more    than    one:    
There are 2 people in the queue.
For    one:    
There is one person on the queue.
For    an    empty    queue:    
Nobody is in the queue!

Dequeue    
If    the    queue    is    empty:
Can't DEQUEUE from an empty list!
IsEmpty        
For    an    empty    queue:
Yes, the QUEUE is empty.
For    a    non-empty    queue:
The QUEUE is NOT empty.    
Front    
If    the    queue    is    empty:    
Nobody in FRONT, the queue is empty!!
Clear    Queue    
If    the    queue    is    empty:    
The QUEUE is ALREADY clear!
100 pts
v.f.19    
Lab    #9A     Implementing    a    Queue     CS1B    
     2    of    4    
Example    Screen    Input/Output        should    be    formatted    as    follows    
QUEUE    MENU:    
1    â€“    ENQUEUE        (Add    a    person)                                
2    â€“    DEQUEUE        (Remove    a    person)    
3    â€“    ISEMPTY                (Is    the    queue    empty?)            
4    â€“    FRONT                            (Who    is    in    front?)    
5    â€“    SIZE                                                (How    many    people    are    there?)    
6    â€“    Clear    the    Queue    
0    â€“    Exit    
    
Enter    a    command?    1    
Who    would    you    like    to    add?    
Enter    Name:                 George    Boole    
Enter    Gender:     M    
Enter    Age:         32    
    
    
edisplay    menu>    
Enter    a    command?    1    
    
Who    would    you    like    to    add?    
Enter    Name:                 Ada    Lovelace    
Enter    Gender:     F    
Enter    Age:     21    
    
    
edisplay    menu>    
Enter    a    command?    1    
    
Who    would    you    like    to    add?    
Enter    Name:                 Grace    Hopper    
Enter    Gender:     F    
Enter    Age:     44    
    
    
edisplay    menu>    
Enter    a    command?    4    
    
The    first    person    in    the    queue    is:    
Name:                            George    Boole    
Gender:     M    
Age:     32    
    
    
edisplay    menu>    
Enter    a    command?    5    
    
There    are    3    people    in    the    queue.    
edisplay    menu>    
Enter    a    command?    2    
    
DEQUEUEING    
Name:                        George    Boole    
Gender:     M    
Age:     32    
    
    
edisplay    menu>    
Enter    a    command?    5    
    
There    are    2    people    in    the    queue.    
    
    
edisplay    menu>    
Enter    a    command?    3    
    
The    QUEUE    is    NOT    empty    
    
    
edisplay    menu>    
Enter    a    command?    4    
    
The    first    person    in    the    queue    is:    
Name:                     Ada    Lovelace    
Gender:     F    
Age:     21    
    
    
edisplay    menu>    
Enter    a    command?    2    
    
DEQUEUEING    
Name:                     Ada    Lovelace    
Gender:     F    
Age:     21
Lab    #9A     Implementing    a    Queue     CS1B    
     3    of    4    
edisplay    menu>    
Enter    a    command?    5    
    
There    is    one    person    in    the    queue.    
    
    
edisplay    menu>    
Enter    a    command?    4    
    
The    first    person    in    the    queue    is:    
Name:                     Grace    Hopper    
Gender:     F    
Age:     44    
    
    
edisplay    menu>    
Enter    a    command?    3    
    
The    QUEUE    is    NOT    empty.    
    
    
edisplay    menu>    
Enter    a    command?    2    
    
DEQUEUEING    
Name:                     Grace    Hopper    
Gender:     F    
Age:     44    
    
    
edisplay    menu>    
Enter    a    command?    5    
    
Nobody    is    in    the    queue!    
    
    
edisplay    menu>    
Enter    a    command?    4    
    
Nobody    in    FRONT,    the    queue    is    empty!!    
    
    
edisplay    menu>    
Enter    a    command?    3    
Yes,    the    QUEUE    is    empty.    
    
edisplay    menu>    
Enter    a    command?    2    

Can't    DEQUEUE    from    an    empty    list!    
    
edisplay    menu>    
Enter    a    command?    1    
    
Who    would    you    like    to    add?    
Enter    Name:                 Alan    Turing    
Enter    Gender:     M    
Enter    Age:     25    
    
    
edisplay    menu>    
Enter    a    command?    1    
    
Who    would    you    like    to    add?    
Enter    Name:         Blaise    Pascal    
Enter    Gender:         M    
Enter    Age:         19    
    
    
edisplay    menu>    
Enter    a    command?    1    
    
Who    would    you    like    to    add?    
Enter    Name:                 Dog    Bert    
Enter    Gender:     M    
Enter    Age:     3    
    
    
edisplay    menu>    
Enter    a    command?    6    
    
CLEARING…    
Alan    Turing    
Blaise    Pascal    
Dog    Bert    
    
The    queue    has    been    CLEARED!
    
    
    
    
    
    
    
    
    
    
Lab    #9A     Implementing    a    Queue     CS1B    
     4    of    4    
    
    
edisplay    menu>    
Enter    a    command?    6    
    
The    QUEUE    is    ALREADY    clear!

    
edisplay    menu>    
Enter    a    command?    8    

****    The    number    12    is    an    invalid    entry                                             ****    
****    Please    input    a    number    between    0    and    6            ****    
    
edisplay    menu>    
Enter    a    command?    a    
    
****    Please    input    a    number    between    0    and    6    ****
    
edisplay    menu>    
Enter    a    command?    0    
    

ules
1. C++ language
2. Functions should be in separate files which is function.cpp
3. A listing of your print heading function (should be in a separate file) which
is MyHeader.h
4. A listing of main.cpp
5. Program must use struct, DO NOT use class
6. Comment (documenting) is needed
Answered 1 days After Apr 10, 2021

Solution

Pulkit answered on Apr 11 2021
159 Votes
new/main.cpp
#include
its/stdc++.h
#include "myheader.h"
using namespace std;
void Enqueue(int age, string name, char gender)
{
node* temp = new node;
size++;
increse size by one
insert element
if (rear == NULL)
{
front = rear = temp;
eturn;
}
ear->next = temp;
ear = temp;
}
void Dequeue()
{
if (front == NULL){
cout
"Can't DEQUEUE from an empty list!"
endl;
eturn;
}
size--;
decrease size by one
node* temp = front;
cout
"DEQUEUEING"
endl;
cout
"Name: "
front->name
endl;
cout
"Gender: "
front->gende
endl;
cout
"Age: "
front->age
endl;
front = front->next;
if (front == NULL)
ear = NULL;
delete (temp);
}
void IsEmpty()
{
if (front == NULL){
cout
"Yes, the QUEUE is empty."
endl;
return;
}
cout
"The QUEUE is NOT empty."
endl;
}
void Front()
{
if (front == NULL)
cout
"Nobody in FRONT, the queue is empty!!"
endl;
else{
cout
"The first person in the queue is:"
endl;
cout
"Name:...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here