C ++ Assignment, computer science homework help

C ++ Assignment, computer science homework help

//Create a simple program that stores the values of 2 variables,_x000D_
//Then perfoms the following operations and store the results in _x000D_
//at least one other variable:_x000D_
//-Addition_x000D_
//-Substration_x000D_
//-Multiplication_x000D_
//-Square_x000D_
//-Cube_x000D_
//-Modulo_x000D_
_x000D_
// if the result of the addition operation is less than five, then tell the user the numbers are low_x000D_
// if the result of the addition operation is greater than five, then tell the user the numbers are high_x000D_
// if the result of the addition operation is five, then tell the user the numbers are good_x000D_
_x000D_
//Wee need to use the control statements to solve some complex problem and direct the flow of execution _x000D_
//of our program:_x000D_
// if_x000D_
// if-else_x000D_
// switch_x000D_
// do-while_x000D_
// while_x000D_
// for_x000D_
// break_x000D_
// return_x000D_
// _x000D_
//Preprocessor Directives_x000D_
//#include "StdAfx.h"_x000D_
_x000D_
#include <iostream>_x000D_
#include <string.h>_x000D_
_x000D_
using namespace std;_x000D_
//Global Declarations_x000D_
//Create my variables (Declaration)_x000D_
	//*** Create variables to hold values_x000D_
	double Variable1;_x000D_
	double Variable2;_x000D_
	//*** Create variable (s) to hold the result of the operations_x000D_
	double OperationResult1, OperationResult2, OperationResult3;_x000D_
_x000D_
//Function Declarations_x000D_
float Addition_Operation();_x000D_
_x000D_
//Define an object for a simple calculator_x000D_
class Simple_Calculator_x000D_
{_x000D_
	public:_x000D_
		//Data members_x000D_
		double Variable1;_x000D_
		double Variable2;_x000D_
		double Result;_x000D_
		_x000D_
		//Constructor for this object_x000D_
		Simple_Calculator()_x000D_
		{_x000D_
			Variable1 = 0;_x000D_
			Variable2 = 0;			_x000D_
			Result = 0;_x000D_
		}_x000D_
		_x000D_
		//Function Set-UP: Initialize your data members_x000D_
		void Set_Up()_x000D_
		{_x000D_
			Variable1 = 4;_x000D_
			Variable2 = 6;			_x000D_
			Result = 0;_x000D_
			_x000D_
		}_x000D_
		_x000D_
		_x000D_
		//Methods (members)_x000D_
		double Addition()_x000D_
		{_x000D_
			//Perform Addition _x000D_
			//*** Add Variable1 and Variable2 and save the result_x000D_
			Result = Variable1 + Variable2;_x000D_
			//*** Output the result on the screen_x000D_
		 	cout << "The resulf of the Addition of " << Variable1 << " + " << Variable2 << " is " << Result << endl;_x000D_
			_x000D_
			// if the result of the addition operation is less than five, then tell the user the numbers are low_x000D_
			if(Result < 5)_x000D_
			{_x000D_
				//if TRUE_x000D_
				cout << "the numbers are low" << endl;_x000D_
				if(Result < 3) //nested if statement_x000D_
					cout << "The numbers are really low!" << endl;_x000D_
			}_x000D_
			else //if FALSE_x000D_
			{_x000D_
				cout << "The result is not less than 5" << endl;_x000D_
			}_x000D_
			// if the result of the addition operation is greater than five, then tell the user the numbers are high_x000D_
			if(Result > 5)_x000D_
			{_x000D_
				cout << "the numbers are High" << endl;_x000D_
			}_x000D_
			// if the result of the addition operation is five, then tell the user the numbers are good_x000D_
			if(Result == 5)_x000D_
			{_x000D_
				cout << "the numbers are good" << endl;_x000D_
			}_x000D_
			_x000D_
			switch(Result)_x000D_
			{_x000D_
				case 0:_x000D_
					cout << "Too Low" << endl;_x000D_
					break;_x000D_
				case 1:_x000D_
					cout << "Too Low" << endl;_x000D_
					break;_x000D_
				case 5:_x000D_
					cout << "Just Right" << endl;_x000D_
					 break;_x000D_
				case 8:_x000D_
					cout << "Too High" << endl;_x000D_
					break;_x000D_
				case 10:_x000D_
					cout << "Too High" << endl;_x000D_
					break;_x000D_
				default:_x000D_
					cout << "Not Happy" << endl;_x000D_
					_x000D_
			}_x000D_
			_x000D_
			if(Result == 0)_x000D_
			{_x000D_
					cout << "Too Low" << endl;_x000D_
			}else if(Result == 1)_x000D_
				{_x000D_
					cout << "Too Low" << endl;_x000D_
				} else if(Result == 5)_x000D_
					{_x000D_
						cout << "Just Right" << endl;_x000D_
					}else if(Result == 8)_x000D_
						{					_x000D_
							cout << "Too High" << endl;_x000D_
						}else if(Result == 10)_x000D_
							{_x000D_
								cout << "Too High" << endl;_x000D_
							}else_x000D_
								{_x000D_
								cout << "Not Happy" << endl;_x000D_
					_x000D_
								}_x000D_
			_x000D_
			return Result;_x000D_
		}_x000D_
		_x000D_
		double Substraction()_x000D_
		{_x000D_
		}_x000D_
		double Multiplication()_x000D_
		{_x000D_
		}_x000D_
		_x000D_
	_x000D_
};_x000D_
_x000D_
//Main Function_x000D_
int main() {_x000D_
	_x000D_
	//Use Algorithm to outline the series of steps required to solve your problem_x000D_
	//Algorithm: Structure Chart, Pseudocode, Flowchart_x000D_
	_x000D_
	//Create an object of type Simple_Calculator_x000D_
	Simple_Calculator myCalculator;_x000D_
	_x000D_
	//Variable to collect the user selection_x000D_
	int UserSelection = 0;_x000D_
	_x000D_
	//Using for loop_x000D_
	for(int i = 0; i < 30; i++)_x000D_
	{_x000D_
	_x000D_
		myCalculator.Set_Up();_x000D_
		_x000D_
		// Ask the user what operation to perform_x000D_
		cout << "Please enter the number corresponding to the operation you would like to perform:" << endl;_x000D_
		cout << "Addition: 1 - Substraction: 2 ..." << endl;_x000D_
		cout << "Addition: 1" << endl;_x000D_
		cout << "Substraction: 2" << endl;_x000D_
		cout << "Division: 3" << endl;_x000D_
		cout << "Cube: 4" << endl;_x000D_
		cout << "Exit: -1" << endl;_x000D_
		_x000D_
		cin >> UserSelection;_x000D_
		_x000D_
		if(UserSelection == -1)_x000D_
		{_x000D_
			break;_x000D_
		}_x000D_
		_x000D_
		if(UserSelection == 1)_x000D_
		{_x000D_
			cout << myCalculator.Addition() << endl;_x000D_
		}else if(UserSelection == 2)_x000D_
			{_x000D_
				cout << myCalculator.Substraction() << endl;_x000D_
			}else if(UserSelection == 3)_x000D_
				{_x000D_
					cout << myCalculator.Division() << endl;_x000D_
				}_x000D_
		_x000D_
		switch(UserSelection)_x000D_
		{_x000D_
			case 1:_x000D_
				cout << myCalculator.Addition() << endl;_x000D_
				break;_x000D_
			case 2:_x000D_
				cout << myCalculator.Substration() << endl;_x000D_
				break;_x000D_
			case 3:_x000D_
				cout << myCalculator.Substration() << endl;_x000D_
				break;_x000D_
			case 4:_x000D_
				_x000D_
				break;_x000D_
			default:_x000D_
				_x000D_
				_x000D_
		}_x000D_
		_x000D_
		_x000D_
	}_x000D_
	_x000D_
	//using while loop_x000D_
	while(UserSelection != -1)_x000D_
	{_x000D_
	_x000D_
		myCalculator.Set_Up();_x000D_
		_x000D_
		// Ask the user what operation to perform_x000D_
		cout << "Please enter the number corresponding to the operation you would like to perform:" << endl;_x000D_
		cout << "Addition: 1 - Substraction: 2 ..." << endl;_x000D_
		cout << "Addition: 1" << endl;_x000D_
		cout << "Substraction: 2" << endl;_x000D_
		cout << "Division: 3" << endl;_x000D_
		cout << "Cube: 4" << endl;_x000D_
		cout << "Exit: -1" << endl;_x000D_
		_x000D_
		cin >> UserSelection;_x000D_
		_x000D_
		if(UserSelection == 1)_x000D_
		{_x000D_
			cout << myCalculator.Addition() << endl;_x000D_
		}else if(UserSelection == 2)_x000D_
			{_x000D_
				cout << myCalculator.Substraction() << endl;_x000D_
			}else if(UserSelection == 3)_x000D_
				{_x000D_
					cout << myCalculator.Division() << endl;_x000D_
				}_x000D_
		_x000D_
		switch(UserSelection)_x000D_
		{_x000D_
			case 1:_x000D_
				cout << myCalculator.Addition() << endl;_x000D_
				break;_x000D_
			case 2:_x000D_
				cout << myCalculator.Substration() << endl;_x000D_
				break;_x000D_
			case 3:_x000D_
				cout << myCalculator.Substration() << endl;_x000D_
				break;_x000D_
			case 4:_x000D_
				_x000D_
				break;_x000D_
			default:_x000D_
				_x000D_
				_x000D_
		}_x000D_
		_x000D_
		_x000D_
	}_x000D_
	_x000D_
	//Assign values to my variables_x000D_
	Variable1 = 25;_x000D_
	Variable2 = 00;_x000D_
	_x000D_
	//Call the Addition function: Function Call_x000D_
	Addition_Operation();_x000D_
	_x000D_
	//Perform Substration Operation_x000D_
	//*** Substract Variable2 from Variable1 and save the result: Substract Operands from one another_x000D_
	OperationResult2 = Variable1 - Variable2;_x000D_
	//*** Output the result of the operation on the screen_x000D_
	cout << "The resulf of the Substration of " << Variable1 << " - " << Variable2 << " is " << OperationResult2 << endl;_x000D_
	_x000D_
	//Perform Multiplication Operation_x000D_
	//*** Multi;ply Variable2 by Variable1 and save the result_x000D_
	OperationResult3 = Variable1 = Variable2;_x000D_
	//*** Output the result of the operation on the screen_x000D_
	cout << "The resulf of the Multiplication of " << Variable1 << " * " << Variable2 << " is " << OperationResult3 << endl;_x000D_
_x000D_
	_x000D_
	return 0;_x000D_
}_x000D_
_x000D_
//Other Function Definitions_x000D_
_x000D_
//Addition function_x000D_
float Addition_Operation()_x000D_
{_x000D_
	//Perform Addition _x000D_
	//*** Add Variable1 and Variable2 and save the result_x000D_
	OperationResult1 = Variable1 + Variable2;_x000D_
	//*** Output the result on the screen_x000D_
	cout << "The resulf of the Addition of " << Variable1 << " + " << Variable2 << " is " << OperationResult1 << 'n';_x000D_
	_x000D_
}_x000D_
//Other Function Definition

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper