### Can someone help me with my calculator?

1. Description
1.1. Goal - The purpose of this program is to use the control structure concepts learned in chapters 4 and 5.
1.2. Requirements – Design and implement a simple calculator.
 Prompts the user to Enter Expression:
 The user enters an expression of the following format;
o operand1 operator operand2
o examples;
 12 * 3 (where12 is operand1, * is the operator, and 3 is operand2)
 45.0 / 15.5 (where 45 is operand1, / is the operator, and 15.5 is operand2)
 -12.5 + 7 (where -12.5 is operand1, + is operator, and 7 is operand2)
 35.5 – 20.2 (where 35.5 is operand1, - is operator, and 20.2 is operand2)
 The program displays the results as illustrated below;
o Result: operand1 operator operand2 = result
o examples;
 Result: 12 * 3 = 36
 Result: 45.0 / 15.5 = 2.90323
 Result: -12.5 + 7 = -5.5
 Result: 35.5 – 20.2 = 15.3
 After the expression is evaluated, results computed and displayed, the user is prompted to Enter another expression <Y/N> ?
o If the user enters Y, then they are prompted to “Enter Expression”
o If the user enters N, then the program displays “Goodbye” and terminates.
o The user is prompted to “Enter another expression <Y/N> ?” until the user enters either a Y or N character.

my calculator is supposed to meet these requirements

Heres my program but I keep getting errors

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273`` ``````// Simple Calculator.cpp : main project file. // Text-printing program #include #include using namespace std; #include void main () { bool bValidOP; int number1; int number2; int answer; char Op; s: number1 = 0; number2 = 0; answer = 0; cout << "Please enter a number and press ENTER: "; cin >> number1; do { p: cout << "Please enter an operator, 'c' to clear, or 'x' to turn off and press ENTER: "; cin >> Op; bValidOP = false; cout << "Please enter another number and press ENTER: "; cin >> number2; switch (Op) { case '+': answer = number1 + number2; break; case '-': answer = number1 - number2; break; case '*': answer = number1 * number2; break; case '/': answer = number1 / number2; break; case 'c': case 'C': bValidOP = false; cout << "Clearing Calculator." << endl; goto s; break; case 'x': case 'X': bValidOP = false; cout << "Turning Off Calculator." << endl; exit (0); break; default: bValidOP = false; cout << "You have entered an invalid operator." << endl; cout << "Please enter +, -, *, /, 'c' or 'x' as operator. " << endl; goto p; break; } cout << "The result is: " << answer << endl; number1 = answer; } while (!bValidOP); }``````

These are the errors I get
1>------ Build started: Project: Simple Calculator, Configuration: Debug Win32 ------
1> Simple Calculator.cpp
1>Simple Calculator.cpp(3): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>Simple Calculator.cpp(22): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(23): error C2065: 'cin' : undeclared identifier
1>Simple Calculator.cpp(27): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(28): error C2065: 'cin' : undeclared identifier
1>Simple Calculator.cpp(31): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(32): error C2065: 'cin' : undeclared identifier
1>Simple Calculator.cpp(52): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(52): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(58): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(58): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(63): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(63): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(64): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(64): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(69): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(69): error C2065: 'endl' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I dont know what I did wrong...
How about change <iostream> to <iostream.h>?
I still get these errors

1>------ Build started: Project: Simple Calculator, Configuration: Debug Win32 ------
1> Simple Calculator.cpp
1>Simple Calculator.cpp(3): warning C4627: '#include <iostream.h>': skipped when looking for precompiled header use
1>Simple Calculator.cpp(22): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(23): error C2065: 'cin' : undeclared identifier
1>Simple Calculator.cpp(27): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(28): error C2065: 'cin' : undeclared identifier
1>Simple Calculator.cpp(31): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(32): error C2065: 'cin' : undeclared identifier
1>Simple Calculator.cpp(52): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(52): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(58): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(58): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(63): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(63): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(64): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(64): error C2065: 'endl' : undeclared identifier
1>Simple Calculator.cpp(69): error C2065: 'cout' : undeclared identifier
1>Simple Calculator.cpp(69): error C2065: 'endl' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
the top of your code should be
 ``123456`` ``````#include #include using namespace std; int main () ......``````

Last edited on
use iostream. don't allow space between include and <iostream>
Im still getting running errors.... and also does anyone know how to make it loop and add the y/n option from my requirements?
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071`` ``````// Simple Calculator.cpp : main project file. // Text-printing program #include "stdafx.h" // This MUST be first include, and in quotes #include #include using namespace std; int main () { float number1; // Don't use int for variables. User may not enter whole numbers float number2; float answer; // answer may not come out as a whole number, so use float char Op, YN = 'Y'; do { number1 = 0.0; number2 = 0.0; answer = 0.0; Op = ' '; cout << "Please enter a number and press ENTER: "; cin >> number1; cout << "Please enter an operator, 'c' to clear, or 'x' to turn off and press ENTER: "; cin >> Op; cout << "Please enter another number and press ENTER: "; cin >> number2; switch (Op) { case '+': answer = number1 + number2; break; case '-': answer = number1 - number2; break; case '*': answer = number1 * number2; break; case '/': answer = number1 / number2; break; case 'c': case 'C': cout << "Clearing Calculator." << endl; number1 = 0; number2 = 0; break; case 'x': case 'X': cout << "Turning Off Calculator." << endl; exit (0); break; default: cout << "You have entered an invalid operator." << endl; cout << "Please enter +, -, *, /, 'c' or 'x' as operator. " << endl; break; } if (Op != 'c') cout << "The result is : " << number1 << " " << Op << " " << number2 << " = " << answer << endl; cout << "Do you wish to enter another calculation? (Y or N )" << endl; cin >> YN; } while ((YN != 'n' && YN != 'N') || Op !='c' ); cout << "Program has ended." << endl << endl; }``````