Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this project you will create a basic calculator program. The calculator can o

ID: 3601006 • Letter: I

Question

In this project you will create a basic calculator program. The calculator can operate in two modes: Standard and Scientific modes. The Standard mode will allow the user to perform the following operations: add, subtract, multiply, and divide. The Scientific mode will allow the user to perform the same functionality as the Standard plus the following: sin x, cos x, tan x The calculator program will first ask the user for the mode to operate in (Standard or Scientific) Sample Output Enter the calculator mode: Standard/Scientific? Standard The program should then ask the user for the operation to execute (+, -, *, /, sin x, cos x, tan x) Sample Output: Enter for addition, '-'for subtractions, '*'for multiplication, '/'for division, 'sin' for sin x, 'cos' 'tan' for tan x: for cos x, If the user enters an invalid operation, output a message telling the user the input is invalid and re-prompt the user for the operation again. Enter '+'for addition, 'for subtractions, '*'for multiplication, /' for division, 'sin' for sin x, 'cos' for cos x, 'tan' for tan x: division Invalid operation entered Enter for addition, '' for subtractions, '*for multiplication, '/' for division, 'sin' for sin x, 'cos' for cos x, tan for tan x: In order to know how many times the user will need to perform the operation, prompt the user for the number of

Explanation / Answer

#include <iostream>

#include <cmath>

using namespace std;

void main()

{

cout<<"WELCOME TO CALCULATOR APPLICATION"<<endl;

calculator();

return;

}

void calculator()

{

String mode,op;

char ch='Y';

while(ch == 'Y' || ch == 'y'){

cout<<"Enter the calculator mode:"<<endl<<"Standard/scientific";

cin>>mode;

cout<<"Enter the operation"<<endl;

cin>>op;

if(mode == "Standard")

{

cout<<"Calculator is in standard mode"<<endl;

if(op == "+") { add(); }

if(op == "-") { sub();}

if(op == "*") { mult(); }

if(op == "/") { div(); }

else {

cout<<"Invalid operation"<<endl<<"Exiting the program"<<endl;

exit(0);}

}

else if (mode == "scientific")

{

cout<<"Calculator is in standard mode"<<endl;

if(op == "+") { add(); }

if(op == "-") { sub(); }

if(op == "*") { mult(); }

if(op == "/") { div(); }

if(op == "sin") { sin(); }

if(op == "cos") { cos(); }

if(op == "tan") { tan(); }

else {

cout<<"Invalid operation"<<endl<<"Exiting the program"<<endl;

exit(0);}

}

else{

cout<<"Wrong mode entered"<<endl<<"Exiting the program"<<endl;

exit(0);

}

cout<<"Start Over? Y/N"<<endl;

cin>>ch;

}

}

void add(){

double numOperands,i,sumTotal=0;

count<<"How many numbers do you want to add"<<endl;

cin<<numOperands;

double sum[numOperands];

cout<<"Enter "<<numOperands<<" operands"<<endl;

for(i = 0; i<numOperands;i++)

cin>>sum[i];

for(i = 0; i<numOperands;i++)

sumTotal += sum[i];

cout<<"Result of addition is : "<<sumTotal<<endl;

}

void sub(){

double numOperands,i,subTotal;

count<<"How many numbers do you want to subtract"<<endl;

cin<<numOperands;

double minus[numOperands];

cout<<"Enter "<<numOperands<<" operands"<<endl;

for(i = 0; i<numOperands;i++)

cin>>minus[i];

subTotal = minus[0];

for(i = 1; i<numOperands;i++)

subTotal -= minus[i];

cout<<"Result of subtraction is : "<<subTotal<<endl;

}

void mult(){

double numOperands,i,multTotal=1;

count<<"How many numbers do you want to multiply"<<endl;

cin<<numOperands;

double mul[numOperands];

cout<<"Enter "<<numOperands<<" operands"<<endl;

for(i = 0; i<numOperands;i++)

cin>>mul[i];

for(i = 0; i<numOperands;i++)

multTotal *= mul[i];

cout<<"Result of multiplication is : "<<multTotal<<endl;

}

void div(){

double numOperands,i,divTotal;

count<<"How many numbers do you want to divide"<<endl;

cin<<numOperands;

double divi[numOperands];

cout<<"Enter "<<numOperands<<" operands"<<endl;

for(i = 0; i<numOperands;i++)

cin>>divi[i];

divTotal = divi[0];

for(i = 1; i<numOperands;i++)

divTotal /= divi[i];

cout<<"Result of division is : "<<divTotal<<endl;

}

void sin(){

double inp, out;

cout<<"Enter the value for which you want to calculate sine value"<<endl;

cin>>inp;

out = sin(inp);

cout<<"Sine of the given input is : "<<out<<endl;

}

void cos(){

double inp, out;

cout<<"Enter the value for which you want to calculate cosine value"<<endl;

cin>>inp;

out = cos(inp);

cout<<"Cosine of the given input is : "<<out<<endl;

}

void tan(){

double inp, out;

cout<<"Enter the value for which you want to calculate tan value"<<endl;

cin>>inp;

out = tan(inp);

cout<<"Tan of the given input is : "<<out<<endl;

}

If this helps please give a thumbs up. Happy Chegging!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote