I am getting an error with the else if statement. It is underlining the else and saying expected a statement. Could someone tell me what i am doing wrong thanks.
1 2 3
elseif ((choice < 1) || (choice > 5));
cout << "Error, please choose from the correct choices: ";
#include<iostream>
usingnamespace std;
int main()
{
float radius, length, width, area;
char choice;
do {
std::cout << "Please choose from the choices listed\n";
std::cout << "1 --Area of a square\n";
std::cout << "2 -- Area of a circle\n";
std::cout << "3 -- Area of a right triangle\n";
std::cout << "4 -- Quit\n";
std::cin >> choice;
if (choice == '1')
{
float length;
std::cout << "Enter length of square.";
std::cin >> length;
std::cout << "Area of the square =" << length*length << "\n\n";
}
elseif (choice == '2')
{
float radius;
std::cout << "Enter the radius of the circle: ";
std::cin >> radius;
std::cout << "Area of a circle is =" << 3.142*radius*radius << "\n\n";
}
elseif (choice == '3')
{
float width;
std::cout << "Enter the length of the right triangle:";
std::cin >> length;
std::cout << "Enter the width of the right traingle: ";
std::cin >> width;
std::cout << "Area of the right triangle =" << length*width / 2 << "\n\n";
elseif ((choice < 1) || (choice > 5))
cout << "Error, please choose from the correct choices: ";
}
}
while (choice != '4');
return 0;
}