Hello,
I'm a beginner in an entry level C++ class. Currently, I have an assignment due tomorrow in which I must write code to use function, and switch statements in a C++ program which can perform arithmetic and trignometric functions depending on the user's input..below I displayed the actual text of the assignment
"In this project, you will program a simple calculator which does basic arithmetic, trigonometric and operations. In this program, you will exercise “function”, “switch” statements in C++ program. (Your program should contain “switch” statement which accepts user input for either “arithmetic” or “trigonometric” calculations.)
Once user input is selected, proper function is called. For example, “arith( )” for arithmetic calculations and “trigono( )” for “trigonometric ones.
Once those functions are called, user is asked to enter his/her desired computation through another case statement. Based on user input, your calculator performs proper computation after accepting user input numbers. The output from computation should be displayed to your monitor.
My actual code that I have done so far is below, I know it is the arithmetic portion...can someone please help me correct any errors I have created and someone help me include trigonometric functions. I'm lost how to include trigonometric functions if someone can help me please :(
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
//Project Homework #3
#include <math.h>
#include <iostream>
using namespace std;
int main () {
cout <<"Welcome to Robert's calculator." <<endl;
int 1,2; //declaring variables
int result; //look for result
int arith(), int trigono()
cout <<"Press 1 for Arithmetic and 2 for Trignometric Calculation: "; //states to user press 1 to use arithmetic calculator and 2 for Trignometric Calculator
cin >> 1;
cin >> 2;
}
int main()
{
double Operand1, Operand2, Result;
char Operator;
cout << "This program allows you to perform an operation on two numbers\n";
cout << "To proceed, enter a number, an operator, and a number:\n";
cin >> Operand1 >> Operator >> Operand2;
switch(Operator)
{
case '+':
Result = Operand1 + Operand2;
break;
case '-':
Result = Operand1 - Operand2;
break;
case '*':
Result = Operand1 * Operand2;
break;
case '/':
Result = Operand1 / Operand2;
break;
}
cout << "\n" << Operand1 << " " << Operator << " "
<< Operand2 << " = " << Result;
cout << "\n\n";
| |