-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (62 loc) · 1.89 KB
/
main.cpp
File metadata and controls
84 lines (62 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
File Name: main.cpp
*/
#include <iostream>
#include "LinkedList.h"
using namespace std;
int main()
{
//A display of the title, my name, and e-mail address
cout << endl;
cout << "+-------------------------------------------------+" << endl;
cout << "| Singly Linked List Implementation |" << endl;
cout << "| Author name: Nathanlie Ortega |" << endl;
cout << "| NathanlieOrtega.Dev@gmail.com |" << endl;
cout << "+-------------------------------------------------+\n" << endl;
LinkedList lst; //Linked List object
int choice = 0;
while(choice != 4) //User menu loop
{
cout << "\nThe Menu:" << endl;
cout << "1. Insert" << endl;
cout << "2. Search" << endl;
cout << "3. Print" << endl;
cout << "4. Exit" << endl;
cout << "Enter Choice: ";
cin >> choice;
if(choice == 1) //Insert option
{
int value;
cout << "\nEnter a Value: ";
cin >> value;
lst.insert(value);
}
else if(choice == 2) //Search Option
{
int searchValue;
cout << "\nEnter a value to search: ";
cin >> searchValue;
if(lst.search(searchValue))
{
cout << searchValue << " value has been found." << endl;
}
else
{
cout << "Entered value cannot be found." << endl;
}
}
else if(choice == 3) //Print option
{
lst.printList(); //Call the print function
}
else if(choice == 4) //Exiting option
{
cout << "\nExiting..." << endl;
}
else
{
cout << "\nInvalid Choice. Please enter the choice number from 1-4 only" << endl;
}
}
return 0;
}