-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_map.cpp
More file actions
70 lines (63 loc) · 1.51 KB
/
main_map.cpp
File metadata and controls
70 lines (63 loc) · 1.51 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
#include <iostream>
#include <string>
#include "number_map.hpp"
#include "name_map.hpp"
#include <cmath>
#include <fstream>
typedef long long int ll;
using namespace std;
int main(){
Number_Map <ll,int> NU(743);
ifstream inp;
inp.open("numbers.txt");
ll phone;
int blnc;
while(inp>>phone>>blnc){
NU.put(phone,blnc);
}
inp.close();
NU.printMap();
cout << endl;
Name_Map <string,string> NA(2531);
ifstream inp1;
inp1.open("names.txt");
string token,meaning;
while(inp1>>token){
getline(inp1,meaning);
NA.put(token,meaning);
}
inp1.close();
NA.printMap();
cout << endl;
char c = 'y';
while( c=='y' || c=='Y'){
int h;
cout << "Please enter 1 to know balance of a phone number and 2 to know meaning of a name " ;
cin >> h ;
if( h==1){
ll number ;
cout << "Please enter number " ;
cin >> number;
while(cin.fail()){
cout << "PLease enter integer input" << endl;
cin.clear();
cin.ignore(256,'\n');
cin >> number ;
}
int k = NU.find(number);
cout << "Number= " << number << "," << " Balance= " << k << endl;
}
else if( h==2){
string word ;
cout << "Please enter name " ;
cin >> word;
string s = NA.find(word);
cout << "Name= " << word << "," << " Meaning= " << s << endl;
}
else{
cout << "Please enter a valid number!!" << endl;
}
cout << "Do u want to continue ?y/n " ;
cin >> c;
}
}