ooplab4.cpp

来自「This code performs the arithmatic operat」· C++ 代码 · 共 76 行

CPP
76
字号
#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 + =
减小字号Ctrl + -
显示快捷键?