C Assignment computer science homework help
//Create a simple program that stores the values of 2 variables, //Then perfoms the following operations and store the results in //at least one other variable: //-Addition //-Substration //-Multiplication //-Square //-Cube //-Modulo // if the result of the addition operation is less than five, then tell the user the numbers are low // if the result of the addition operation is greater than five, then tell the user the numbers are high // if the result of the addition operation is five, then tell the user the numbers are good //Wee need to use the control statements to solve some complex problem and direct the flow of execution //of our program: // if // if-else // switch // do-while // while // for // break // return // //Preprocessor Directives //#include "StdAfx.h" #include <iostream> #include <string.h> using namespace std; //Global Declarations //Create my variables (Declaration) //*** Create variables to hold values double Variable1; double Variable2; //*** Create variable (s) to hold the result of the operations double OperationResult1, OperationResult2, OperationResult3; //Function Declarations float Addition_Operation(); //Define an object for a simple calculator class Simple_Calculator { public: //Data members double Variable1; double Variable2; double Result; //Constructor for this object Simple_Calculator() { Variable1 = 0; Variable2 = 0; Result = 0; } //Function Set-UP: Initialize your data members void Set_Up() { Variable1 = 4; Variable2 = 6; Result = 0; } //Methods (members) double Addition() { //Perform Addition //*** Add Variable1 and Variable2 and save the result Result = Variable1 + Variable2; //*** Output the result on the screen cout << "The resulf of the Addition of " << Variable1 << " + " << Variable2 << " is " << Result << endl; // if the result of the addition operation is less than five, then tell the user the numbers are low if(Result < 5) { //if TRUE cout << "the numbers are low" << endl; if(Result < 3) //nested if statement cout << "The numbers are really low!" << endl; } else //if FALSE { cout << "The result is not less than 5" << endl; } // if the result of the addition operation is greater than five, then tell the user the numbers are high if(Result > 5) { cout << "the numbers are High" << endl; } // if the result of the addition operation is five, then tell the user the numbers are good if(Result == 5) { cout << "the numbers are good" << endl; } switch(Result) { case 0: cout << "Too Low" << endl; break; case 1: cout << "Too Low" << endl; break; case 5: cout << "Just Right" << endl; break; case 8: cout << "Too High" << endl; break; case 10: cout << "Too High" << endl; break; default: cout << "Not Happy" << endl; } if(Result == 0) { cout << "Too Low" << endl; }else if(Result == 1) { cout << "Too Low" << endl; } else if(Result == 5) { cout << "Just Right" << endl; }else if(Result == 8) { cout << "Too High" << endl; }else if(Result == 10) { cout << "Too High" << endl; }else { cout << "Not Happy" << endl; } return Result; } double Substraction() { } double Multiplication() { } }; //Main Function int main() { //Use Algorithm to outline the series of steps required to solve your problem //Algorithm: Structure Chart, Pseudocode, Flowchart //Create an object of type Simple_Calculator Simple_Calculator myCalculator; //Variable to collect the user selection int UserSelection = 0; //Using for loop for(int i = 0; i < 30; i++) { myCalculator.Set_Up(); // Ask the user what operation to perform cout << "Please enter the number corresponding to the operation you would like to perform:" << endl; cout << "Addition: 1 - Substraction: 2 ..." << endl; cout << "Addition: 1" << endl; cout << "Substraction: 2" << endl; cout << "Division: 3" << endl; cout << "Cube: 4" << endl; cout << "Exit: -1" << endl; cin >> UserSelection; if(UserSelection == -1) { break; } if(UserSelection == 1) { cout << myCalculator.Addition() << endl; }else if(UserSelection == 2) { cout << myCalculator.Substraction() << endl; }else if(UserSelection == 3) { cout << myCalculator.Division() << endl; } switch(UserSelection) { case 1: cout << myCalculator.Addition() << endl; break; case 2: cout << myCalculator.Substration() << endl; break; case 3: cout << myCalculator.Substration() << endl; break; case 4: break; default: } } //using while loop while(UserSelection != -1) { myCalculator.Set_Up(); // Ask the user what operation to perform cout << "Please enter the number corresponding to the operation you would like to perform:" << endl; cout << "Addition: 1 - Substraction: 2 ..." << endl; cout << "Addition: 1" << endl; cout << "Substraction: 2" << endl; cout << "Division: 3" << endl; cout << "Cube: 4" << endl; cout << "Exit: -1" << endl; cin >> UserSelection; if(UserSelection == 1) { cout << myCalculator.Addition() << endl; }else if(UserSelection == 2) { cout << myCalculator.Substraction() << endl; }else if(UserSelection == 3) { cout << myCalculator.Division() << endl; } switch(UserSelection) { case 1: cout << myCalculator.Addition() << endl; break; case 2: cout << myCalculator.Substration() << endl; break; case 3: cout << myCalculator.Substration() << endl; break; case 4: break; default: } } //Assign values to my variables Variable1 = 25; Variable2 = 00; //Call the Addition function: Function Call Addition_Operation(); //Perform Substration Operation //*** Substract Variable2 from Variable1 and save the result: Substract Operands from one another OperationResult2 = Variable1 - Variable2; //*** Output the result of the operation on the screen cout << "The resulf of the Substration of " << Variable1 << " - " << Variable2 << " is " << OperationResult2 << endl; //Perform Multiplication Operation //*** Multi;ply Variable2 by Variable1 and save the result OperationResult3 = Variable1 = Variable2; //*** Output the result of the operation on the screen cout << "The resulf of the Multiplication of " << Variable1 << " * " << Variable2 << " is " << OperationResult3 << endl; return 0; } //Other Function Definitions //Addition function float Addition_Operation() { //Perform Addition //*** Add Variable1 and Variable2 and save the result OperationResult1 = Variable1 + Variable2; //*** Output the result on the screen cout << "The resulf of the Addition of " << Variable1 << " + " << Variable2 << " is " << OperationResult1 << 'n'; } //Other Function Definition
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!
NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.

