Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 52.14.88.137
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/cchansen/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/cchansen/assignment8.txt
Script started on Sun 05 Apr 2009 11:29:27 PM EDT
[cchansen@zeus cchansen]$ cat assignment8.cpp
//      Title: 		assignment8.cpp 
//      Author: 	Caitlin Hansen
//      Teacher: 	Dr. Wang
//      Due: 		April 6,2009
//
//      Goal:		The program creates a list by using vectors, allowing the user to 
//              	insert, sort, and print words.
//

#include <iostream>     // for endl, setw, fixed..
#include <vector>       // for vector class template
#include <algorithm>    // for sort(..) for vector objects

using namespace std;    // for cin/cout

void menu();

int main()
{
        vector<string> myList;
        string temp;
        char ch;
        menu();

        cin >> ch;

        while(tolower(ch) != 'q')
        {       cout << "You choose - " << ch;
                if( tolower(ch) == 'i')
                {
                        cout << "\n\nInsert a word: ";
                        cin >> temp;
                        myList.push_back(temp);
                        cout << "\n" << temp
                         << " is inserted to the list.\n";
                }
                else if(tolower(ch) == 'p')
                {       cout << "\n The List is: ";

                        for( int i=0; i  < myList.size(); i++)
                                cout << myList[i] << "  ";
                        cout << endl;
                }
                else if(tolower(ch) == 's')
                {       sort(myList.begin(), myList.end() );
                        cout << "\n The list is sorted.\n";
                }
                else if(tolower(ch) == 'd')
                {       sort(myList.begin(), myList.end(), greater<string>() );
                        cout << "\nThe list is sorted to descending order.\n";

                }
                else if(tolower(ch) == 'r')
                {       myList.pop_back();
                        cout << endl;
                        cout << "The last word was removed.\n";
                }
                cout << "The number of items in the list are: "
                        << myList.size();

                menu();
                cin >> ch;
        }

        cout << "\n\nYou are finished.\n\n";
        return 0;
}

void menu()
{       cout << "\n\n   List Game\n";
        cout <<"------------------------------------\n";
        cout << "I      Insert a word.\n";
        cout << "P      Print the list.\n";
        cout << "S      Sort to ascending list.\n";
        cout << "D      Sort to descending order.\n";
        cout << "R      Remove the last word.\n";
        cout << "Q      Quit.\n"; 
        cout << "====================================";
        cout << endl;
        cout << "Your Choice: ";
}

[cchansen@zeus cchansen]$ cat assignment8.cppexit./assign7.outcat assignment7.cpp./assign7.out.out8.out


   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: I
You choose - I

Insert a word: Faculty

Faculty is inserted to the list.
The number of items in the list are: 1

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: I
You choose - I

Insert a word: Summer

Summer is inserted to the list.
The number of items in the list are: 2

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: I
You choose - I

Insert a word: Preparation

Preparation is inserted to the list.
The number of items in the list are: 3

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: I
You choose - I

Insert a word: Appointment

Appointment is inserted to the list.
The number of items in the list are: 4

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: I
You choose - I

Insert a word: Ask

Ask is inserted to the list.
The number of items in the list are: 5

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: I
You choose - I

Insert a word: Future

Future is inserted to the list.
The number of items in the list are: 6

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: I
You choose - I

Insert a word: Fall

Fall is inserted to the list.
The number of items in the list are: 7

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: S
You choose - S
 The list is sorted.
The number of items in the list are: 7

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: P
You choose - P
 The List is: Appointment  Ask  Faculty  Fall  Future  Preparation  Summer  
The number of items in the list are: 7

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: D
You choose - D
The list is sorted to descending order.
The number of items in the list are: 7

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: P
You choose - P
 The List is: Summer  Preparation  Future  Fall  Faculty  Ask  Appointment  
The number of items in the list are: 7

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: Q R
You choose - R
The last word was removed.
The number of items in the list are: 6

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: P
You choose - P
 The List is: Summer  Preparation  Future  Fall  Faculty  Ask  
The number of items in the list are: 6

   List Game
------------------------------------
I      Insert a word.
P      Print the list.
S      Sort to ascending list.
D      Sort to descending order.
R      Remove the last word.
Q      Quit.
====================================
Your Choice: Q


You are finished.

[cchansen@zeus cchansen]$ exit

Script done on Sun 05 Apr 2009 11:31:42 PM EDT

Stv3n404 - 2023