C++, syntax errors
I am trying to make a program that computes the area of a given shape, I have eliminated most of the fat finger errors that I made, but can't seam to get rid of these errors. Any help would be greatly appreciated.
The Code
Code:
#include <iostream>
using namespace std;
void circle ( );
void rectangle ( );
void square ( );
int main()
{
char choice = ' '; // Variable declarations
char doAgain = 'Y';
do
{
cout << "You have the following choices:" << endl; // making a menu
cout << "C -- circle" << endl;
cout << "S -- square" << endl;
cout << "R -- rectangle" << endl
cin >> "choice" ;
choice = toupper(choice); // makes the case upercase
switch (choice)
{
case 'C': circle( ); break; // nifty function calls
case 'S': square( ); break;
case 'R': rectangle( ); break;
default: cout << "Invalid choice option. Please try again." << endl << endl;
}
cout << "Would you like to do another arithmetic problem?";
cin >> doAgain;
}while( toupper(doAgain) == 'Y');
return 0;
}
void circle ( )
{
int operand1 ;
float answer ;
d
cout << "Enter the radius of the circle. " << endl;
cin >> operand1;
answer = (3.141592)*(operand1^2)
cout << "The area of the circle is " << answer << endl;
}
void square ( )
{
int operand1 ;
int operand2 ;
float answer ;
cout << "Enter the two sides of the square seperated by a space." << endl;
cin >> operand1 >> operand2;
answer = (operand1*operand2)
cout <<"The area of the square is " << answer << endl;
}
void rectangle ( )
{
int operand1 ;
int operand2 ;
float answer ;
cout <<"Enter the two side of the rectangle seperated by a space." << endl;
cin >> operand1 >> operand2;
answer = (operand1*operand2)
cout <<"The area of the rectangle is " <<answer <<endl;
}
The errors:
area_calculator.cpp: In function `int main()':
area_calculator.cpp:50: error: syntax error before `>>' token
area_calculator.cpp: In function `void circle()':
area_calculator.cpp:82: error: syntax error before `<<' token
area_calculator.cpp: In function `void square()':
area_calculator.cpp:96: error: syntax error before `<<' token
area_calculator.cpp: In function `void rectangle()':
area_calculator.cpp:110: error: syntax error before `<<' token