forked from BitSails/hellogit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.cpp
More file actions
86 lines (62 loc) · 1.36 KB
/
Library.cpp
File metadata and controls
86 lines (62 loc) · 1.36 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
85
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include "Books.h"
using namespace std;
int linearSearch(vector<Books>&, string);
int main()
{
vector<Books>Obooks; //vector of object overdue books
string member;
int days,amt,num;
cout<<"\nPlease enter the following information for overdue books";
cout<<"\n How many late members are there? ";
cin>>amt;
for (int x=0; x<amt; x++)
{
cout<<"\nPlease enter member's name: ";
cin>>member;
cout<<"Please enter the number of days late: ";
cin>>days;
Books lateMembers(member,days);
Obooks.push_back(lateMembers);
cout<<endl;
}
cout<<endl;
for (int x=0; x<amt; x++)
{
cout<<"Members with outstanding fees: "<<endl;
cout<<Obooks[x].getName()<<" : $";
cout<<fixed<<setprecision(2)<<Obooks[x].getFee();
cout<<endl;
}
cout<<endl;
string value;
cout<<"Please enter a name to be searched(to end input,enter '!'): ";
cin>>value;
while(value != "!")
{
num= linearSearch(Obooks,value);
if (num==-1)
{
cout<<"Name was not found"<<endl;
}
else
cout<<"Name found at index: "<<num<<endl;
cout<<"\nEnter a name to be searched for: ";
cin>>value;
}
return 0;
}
int linearSearch (vector<Books>& Data, string key)
{
for(unsigned int i=0; i<Data.size();i++)
{
if (Data[i].getName() == key)
{
return i;
}
}
return -1;
}