Hello,
I am trying to do this assignment in the book. My objective is to create an interactive program which will calculate areas of a square or a triangle depending on the user input 's' or 't'. I am gone about 40% of the book so they dont expect me to use any kind of fancy stuff, just using If statement
Anyhow, here is my code and the errors are C2676 and C2784 in Visual Studio
Please tell me what i am doing wrong there
Thank you
// greg lyukshin
// chapter 4.4 program 2
// compound IF statement for area of the square and triangle
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
char s,
t;
float area,
side,
base,
height;
string letter;
cout << "enter either 's' to find area of square or 't' to find area of triangle: " << endl;
cin >> letter;
if(letter == 's')
{ cout << "enter side: " << endl;
cin >> side;
area = pow(side,2);
cout << "area of square is " << area << endl;
}
else
if(letter == 't')
{ cout << "enter base: " << endl;
cin >> base;
cout << "enter height: " << endl;
cin >> height;
area = (1/2) * base * height;
cout << "area of triangle is " << area << endl;
}
system("pause");
return 0;
}