Repository navigation
Expand file tree
/
Copy pathexercise.cpp
More file actions
60 lines (55 loc) · 1.64 KB
/
Copy pathexercise.cpp
File metadata and controls
60 lines (55 loc) · 1.64 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
#include <iostream>
#include <cmath>
using namespace std;
class simplecalculator{
protected:
int a, b;
char c;
public:
void setvalsimple(void){
cout<<"enter the value of a for simple calculations "<<endl;
cin>>a;
cout<<"enter the value of b for simple calculations "<<endl;
cin>>b;
}
void performsimple(void){
cout<<"The value of a+b is "<<a+b<<endl;
cout<<"The value of a-b is "<<a-b<<endl;
cout<<"The value of a*b is "<<a*b<<endl;
cout<<"The value of a/b is "<<a/b<<endl;
}
};
class scientificcalculator {
protected:
int a, b;
char c;
public:
void setvalscientific(void){
cout<<"enter the value of a for simple calculations "<<endl;
cin>>a;
cout<<"enter the value of b for simple calculations "<<endl;
cin>>b;
}
void performscientific(void){
cout<<"The value of cos(a) is "<<cos(a)<<endl;
cout<<"The value of cos(b) "<<cos(b)<<endl;
cout<<"The value of sin(a) is "<<sin(a)<<endl;
cout<<"The value of sin(b) is "<<sin(b)<<endl;
}
};
class hybridcalculator : public simplecalculator , public scientificcalculator{
};
int main(){
// simplecalculator c;
// c.setval();
// c.perform();
// scientificcalculator a;
// a.setval();
// a.perform();
hybridcalculator h;
h.setvalsimple();
h.performsimple();
h.setvalscientific();
h.performscientific();
return 0;
}