-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops_concept2.cpp
More file actions
47 lines (44 loc) · 923 Bytes
/
Copy pathoops_concept2.cpp
File metadata and controls
47 lines (44 loc) · 923 Bytes
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
#include<iostream>
#include<string>
using namespace std;
class Employee{
string s;
public:
void read();
void check_bin();
void one_compliment();
void display();
} ep;
void Employee::read(){
cout<<"Enter the bin code"<<endl;
cin>>s;
}
void Employee::check_bin(){
for(int i=0;i<s.length();i++){
if((s.at(i)!='0')&&(s.at(i)!='1')){
cout<<"String is not bin"<<endl;
exit(0);
}
}
}
void Employee::one_compliment(){
for(int i=0;i<s.length();i++){
if(s.at(i)=='0')
s.at(i)='1';
else
s.at(i)='0';
}
}
void Employee::display(){
cout<<s<<endl;
}
int main(){
ep.read();
ep.check_bin();
cout<<"String before ones compliment"<<endl;
ep.display();
ep.one_compliment();
cout<<"String after ones compliment"<<endl;
ep.display();
return 0;
}