Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN VISUAL STUDIO CLR CONSOLE APPLICATION, I NEED TO MODIFY THE BELOW PROGRAME. AFTER EACH OPERATION IT SHOULD ASK WHETHER TO CONTINUE OR EXIT. IF

IN VISUAL STUDIO CLR CONSOLE APPLICATION, I NEED TO MODIFY THE BELOW PROGRAME. AFTER EACH OPERATION IT SHOULD ASK WHETHER TO CONTINUE OR EXIT. IF YES USER SHOULD BE ABLE TO PERORM OTHER OPERATION. IF NOT THE WINDOW SHOULD GET EXIT.

/*

Class: EEGR161 Professor: Chris Hyousseu Student: Ahmed Samsudeen Program: Advanced Calculator Description: Implements and stimulating an Advanced Calculator functions Date: February - 28 - 2016

*/

#include "stdafx.h" # include #include #include using namespace std;

//function declarations //Global Declarations

//Object prototype/definition/blueprint of type class : myCalculators

// Data members //Methods in available functions of the calculator (Declarations)

int factorial(); //function declaration for factorial operation float quad(float a, float b, float c); //function declaration for Quadratic operation float slope(); //function declaration for Slope operation float addition(); //function declaration for Addition operation float subtraction(); //function declaration for Subtraction operation float multiplication(); //function declaration for Multiplication operation float division(); //function declaration for Division operation float square(); //function declaration for Square operation float cube(); //function declaration for Cube operation float power(); //function declaration for Power operation float squareroot(); //function declaration for squareroot operation float percentage(); //function declaration for Percentage operation float average(); //function declaration for Average operation float proceed(); //function declaration for Continue operation float exit(); //function declaration for Exit operation

//The above are the methods of declaring detailed definitons of the blueprints : myCalculator /* Main Function: Entry and Exit point of the program Summary: */

//execution starts here int main() { char o; float num1, num2, f, a, b, c; //Variables uses in the Advanced calculator to collect the result of the operations

cout << "Enter operator either Plus (+) or Minus (-) or Multiplication (*) or Divison (/) or Square (^) or Cube (c) or Power (p) or Squareroot (sqr) or Percentage (%) or Average (avg) f for Factorial or q for Quadratic or s for Slope or Y for Proceed or E for Exit: "; //Input the choice to perform the operation as stated above cin >> o; switch (o) { case '+': cout << " enter num1 and num2 " << endl; //Input Values for Addition Function cin >> num1 >> num2; //perform and display the added values cout << " addition of " << num1 << " and " << num2 << " is " << num1 + num2 << endl; break;

cout << "Do you wish to proceed ? Press Y to or N to Exit."; cin >> c; // if Y then go for subtraction followed by date of birth if (c == 'Y')

case '-': cout << " enter num1 and num2 " << endl; //Input Values for Substraction Function cin >> num1 >> num2; //perform and display the difference values cout << " subtraction of " << num1 << " and " << num2 << " is " << num1 - num2 << endl; break;

case '*': cout << " enter numb1 and num2 " << endl; //Input values for Multiplication Function cin >> num1 >> num2; //perform and display the multiplication values cout << " multiplication of " << num1 << " and " << num2 << " is " << num1 * num2 << endl; break;

case '/': cout << " enter num1 and num2 " << endl; //Input values for Division Function cin >> num1 >> num2; //perform and display the division values cout << " division of " << num1 << " and " << num2 << " is " << num1 / num2 << endl; break;

case '^': cout << " enter num1 " << endl; //Input values for Square Function cin >> num1; //perform and display the square values cout << " square of " << num1 << " is " << num1 * num1 << endl; break;

case 'c': cout << " enter num1 " << endl; //Input values for Cube Function cin >> num1; //perform and display the cube values cout << " cube of " << num1 << " is " << (num1 * num1 * num1) << endl; break;

case 'p': cout << " enter num1 and num2 " << endl; //Input values for Power Function cin >> num1 >> num2; //perform and display the power values cout << " power of " << num1 << " and " << num2 << " is " << pow(num1, num2) << endl; break;

case '%': cout << " enter num1 and num2 " << endl; //Input values for Percentage Function cin >> num1 >> num2; //perform and display the percentage values cout << " percentage of " << num1 << " and " << num2 << " is " << (num1 + num2) * (100 / 100) << " % " << endl; break;

case 'sqr': cout << " enter num1 " << endl; //Input values for Squarerrot Function cin >> num1; //perform and display the squarerrot values cout << " squarerrot of " << num1 << " is " << (sqrt(num1)) << endl; break;

case 'avg': cout << " enter num1 and num2 " << endl; //Input values for Average Function cin >> num1 >> num2; //perform and display the average values cout << " average of " << num1 << " and " << num2 << " is " << (num1 + num2) / 2 << endl; break;

case 'q': cout << " Enter the values of a,b and c" << endl; cin >> a >> b >> c; //function call to quadratic function with a,b,c values quad(a, b, c); break;

case 's': //function call to slope function slope(); break;

case 'f': //function call to factorial function factorial(); break;

} getch(); return 0; }

//Definition for finding slope function float slope() {

float dy, dx, x1, x2, y1, y2, slope; cout << " enter values of x1,y1,x2,y2" << endl; //input x1,y1,x2 and y2 values which are required to find the slope cin >> x1 >> y1 >> x2 >> y2; dx = x2 - x1; dy = y2 - y1; //formula to find slope slope = dy / dx; cout << "Slope of the line with end points (" << x1 << ", " << y1 << " and (" << x2 << ", " << y2 << ") = "; //display slope value cout << slope << " "; return 0; }

int factorial() {

unsigned int n; unsigned factorial = 1; cout << "Enter a positive integer: "; //entering only positive input cin >> n; //finding factorial using only loops for (int i = 1; i <= n; ++i) { factorial *= i; } //Displaying the factorial value cout << "Factorial of " << n << " = " << factorial; return 0; }

float quad(float a, float b, float c) {

float x1, x2, determinant, realPart, imaginaryPart; //finding the determinant which is part of formula to find the roots determinant = b*b - 4 * a*c; if (determinant > 0) { x1 = (-b + sqrt(determinant)) / (2 * a); x2 = (-b - sqrt(determinant)) / (2 * a); cout << "Roots are real and distinct." << endl; cout << "x1 = " << x1 << endl; cout << "x2 = " << x2 << endl; }

else if (determinant == 0) { cout << "Roots are real and equal." << endl; x1 = (-b + sqrt(determinant)) / (2 * a); cout << "x1 = x2 =" << x1 << endl; }

else { realPart = -b / (2 * a); imaginaryPart = sqrt(fabs(determinant)) / (2 * a); cout << "Roots are imaginary." << endl; cout << "x1 = " << realPart << "+" << "i" << imaginaryPart << endl; cout << "x2 = " << realPart << "-" << "i" << imaginaryPart << endl; }

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

=+b. a homeowner with a fixed-rate mortgage

Answered: 1 week ago

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

LO12.1 List the characteristics of pure monopoly.

Answered: 1 week ago