Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I keep getting an error saying \"hello world\" for this problem below using visu

ID: 3754016 • Letter: I

Question

I keep getting an error saying "hello world" for this problem below using visual studio for C++. I have attached below the code that i used!

Write a program that displays the following menu:

Enter 1 to calculate the area of a circle

Enter 2 to calculate the area of a rectangle

Enter 3 to calculate the area of a triangle

If the user enters 1, it prompts the user for the radius and calculates the area of a circle with that radius. If the user enters 2, it prompts the user for the length and width and calculates the area of a rectangle with these dimensions (area = length * width). If the user enters 3, it prompts the user for the base and height and calculates the area of a triangle with these dimensions (area= 1/2 base * height). If the user enters any other number outside the range 1-3, the program displays an error message. You must

#include "pch.h"
#include <iostream>
#define PI 3.142
#include<math.h>

using namespace std;
int main()
{

int
cout << "Enter 1 to calculate the area of a circle Enter 2 to calculate the area of a rectangle Enter 3 to calculate the area of a triangle ";
cin >> choice;
float area;
switch (choice)
{
case 1:
  float r;
  cout<<"Enter radious:";
  cin>>r;
  area = PI * pow(r, 2);
  cout <<"Area of circle is: " <<area<<endl;
  break;
case 2:
  float length,width;
  cout<<"Enter length:";
  cin>>length;
  cout<<"Enter width:";
  cin>>width;
  area = length * width;
  cout <<"Area of Rectangle is:" <<area<<endl;
  break;
case 3:
  float height,base;
  cout<<"Enter base:";
  cin>>base;
  cout<<"Enter height:";
  cin>>height;
  area = (base*height) / 2;
     cout <<"Area of Triangle is:" <<area<<endl;
     break;
}
}

Explanation / Answer


#include <iostream>
#include<math.h>

using namespace std;

#define PI 3.142

int main()
{

int choice;
cout << "Enter 1 to calculate the area of a circle Enter 2 to calculate the area of a rectangle Enter 3 to calculate the area of a triangle ";
cin >> choice;
float area;
switch (choice)
{
case 1:
float r;
cout<<"Enter radious:";
cin>>r;
area = PI * pow(r, 2);
cout <<"Area of circle is: " <<area<<endl;
break;
case 2:
float length,width;
cout<<"Enter length:";
cin>>length;
cout<<"Enter width:";
cin>>width;
area = length * width;
cout <<"Area of Rectangle is:" <<area<<endl;
break;
case 3:
float height,base;
cout<<"Enter base:";
cin>>base;
cout<<"Enter height:";
cin>>height;
area = (base*height) / 2;
cout <<"Area of Triangle is:" <<area<<endl;
break;
default:
cout<<"wrong choice";
break;
}

return 0;
}

OUtput:

----------

Enter 1 to calculate the area of a circle   
Enter 2 to calculate the area of a rectangle   
Enter 3 to calculate the area of a triangle   
2   
Enter length:4
Enter width:5   
Area of Rectangle is:20

---------------------------------------

Enter 1 to calculate the area of a circle   
Enter 2 to calculate the area of a rectangle   
Enter 3 to calculate the area of a triangle   
5   
wrong choice

----------------------------