-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAss8_Exception.cpp
57 lines (45 loc) · 1009 Bytes
/
Ass8_Exception.cpp
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
#include <iostream>
using namespace std;
int main()
{
int age;
float income;
string city;
char answer;
try
{
cout<<"Enter age\n";
cin>>age;
if(age > 55 || age < 18)
throw(age);
cout<<"Enter income\n>>";
cin>>income;
if(income > 100000 || income < 50000)
throw(income);
cout<<"Enter city\n>>";
cin>>city;
if(!city.compare("mumbai") || !city.compare("banglore") || !city.compare("chennia"))
throw(city);
cout<<"Do you have 4 wheeler(y/n)\n>>";
cin>>answer;
if(answer == 'n')
throw(answer);
}
catch(int)
{
cout<<"Age is inappropriate!!!\n";
}
catch(float)
{
cout<<"Income is not in required range!!!\n";
}
catch(string)
{
cout<<"You do not belong to the required city!!!\n";
}
catch(char)
{
cout<<"You must have 4 wheeler!!!\n";
}
return 0;
}