⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rambo.cpp

📁 Kudiyon ne dekho tera naam rakheya rambo rambo kudiyon ne dekho tera naam rakheya rambo rambo kudiyo
💻 CPP
字号:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

void instructUser();
double doDivideZero(double &);




int main()
{
	instructUser();
	
	
	double displayedVal;
	double newEntry;
	char command_character ;

	
	displayedVal = 0.0;

	
	cout << "  Enter accepted Operator:" ;
	cin >> command_character;
	while (command_character != 'Q' || command_character != 'q')
	{
		switch(command_character)
		{
		case 'c':
		case 'C': displayedVal = 0.0;
				  break;
		case '+': cout << "  Enter Number:";
				  cin >> newEntry;
				  displayedVal = displayedVal + newEntry;
				  break;
		case '-': cout << "  Enter Number:";
				  cin >> newEntry;
				  displayedVal = displayedVal - newEntry;
				  break;
		case '*': cout << "  Enter Number:";
				  cin >> newEntry;
				  displayedVal = displayedVal * newEntry;
				  break;
		case '/': cout << "  Enter Number:";
			      cin >> newEntry;
				  displayedVal = displayedVal / newEntry;
				  if (newEntry == 0)
				  {
					  doDivideZero(double &);
				  }
				  
				  break;
		case '^': cout << "  Enter Number:";
				  cin >> newEntry;
				  displayedVal = pow (displayedVal,newEntry);
				  break;
				  default : cout << "  Unacceptable Operator(" << command_character << ")" << endl;
		}
		cout << "  The result so far is: " <<displayedVal<< endl;
		cout << "  Enter Operator:";
		cin >> command_character;
		
		
	}




	system ("pause");
	return 0;
}

void instructUser()

{
		cout << "                    " <<endl;
		cout << "  ***************************************************************************" <<endl;
		cout << "  *  This program takes your input and selected mathematical operator       *" <<endl;
		cout << "  *  and returns the answer to the screen. If an illegal operator is        *" << endl;
		cout << "  *  selected, an error message will be displayed. Be careful which         *" <<endl;
		cout << "  *  operator you select because the program depends on you for input.      *" <<endl;
		cout << "  *  The only error check function it has, is for unacceptable opreators.   *" <<endl;
		cout << "  *  Acceptable operators are : (+ , - , / , * ,^,c). The character c sets  *" <<endl;
		cout << "  *  the value stored to ZERO. Enter Q to exit. ENJOY YOUR PROGRAM !!!!!!   *" <<endl;
		cout << "  ***************************************************************************" <<endl;
		cout << "                     " <<endl;



}

double doDivideZero(double &)
{
	double newEntry;
	double displayedVal;
	newEntry =0;
	displayedVal = 0.0;
	


	if (newEntry !=0)
	{
		displayedVal = displayedVal / newEntry;
	} else cout << "Wrong Operation, Cannot Divide by Zero" << endl;
	
		
		
	
	return 0;	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -