📄 ooplab4.cpp
字号:
#include<iostream.h>
#include<conio.h>
#include<math.h>
class matlab
{
private:
int operation, choice;
float a,b,c,z;
public:
float arith(float x, float y, int operation)
{
switch (operation)
{
case 0:
z=x+y;
break;
case 1:
z=x-y;
break;
case 2:
z=x*y;
break;
case 3:
z=x/y;
break;
}
return z;
}
float trig(float x, int operation)
{
if(operation==0)
{
z=cos(x);
}
return z;}
void ui()
{
clrscr();
cout<<"Menu"<<endl;
cout<<"press 1 for arithmatic operations"<<endl;
cout<<"press 2 for trignometric operations"<<endl;
cin>>choice;
if(choice==1)
{
clrscr();
cout<<"press 0 for addition"<<endl;
cout<<"press 1 for subtraction"<<endl;
cout<<"press 2 for multiplicaiton"<<endl;
cout<<"press 3 for division"<<endl;
cout<<"Enter first digit \n"; cin>>a;
cout<<"Enter 2nd digit \n";cin>>b;
cout<<"Enter which function to perform \n"; cin>>operation;
c=arith(a,b,operation);
cout<<"Result="<<c<<endl;
}
if(choice==2)
{
clrscr();
cout<<"press 0 for sin"<<endl;
cout<<"press 1 for cos"<<endl;
}
}
};
int main()
{
matlab obj1;
obj1.ui();
getch();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -