Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intro to C++ #include #include using namespace std; int main() { cout < < AREA CALCULATOR < < 1. Circle < < 2.

Intro to C++

#include #include

using namespace std;

int main() { cout << "AREA CALCULATOR " << "1. Circle " << "2. Square " << "3. Rectangle ";

int menu_item; cout << "Menu item: "; cin >> menu_item; cout << endl;

double pi = 3.1; // code this variable before the switch statement to make sure it gets initialized - otherwise, you will get an error double area; switch (menu_item) { case 1: cout << "CIRCLE" << endl;

double radius; cout << "Radius: "; cin >> radius;

area = pi * pow(radius, 2.0); break; case 2: cout << "SQUARE" << endl;

double height; cout < "Height: "; cin >> height;

area = pow(height, 2.0); break; case 3: cout << "RECTANGLE" << endl;

cout << "Height: "; cin >> height; // this variable has already been declared by case 2 - no need to declare again in case 2

double width; cout << "Width: "; cin >> height;

area = height * 1; break; default: cout << "Inalid menu item! "; return 0; // exit program immediately - don't execute code after switch statement }

cout << "Area: " << area << " "; cout << "Bye! ";

return 0; }

There are several bugs in the code. Find the errors and fix the bugs. When you are done the output should look like this:

AREA CALCULATOR 1. Circle 2. Square 3. Rectangle
Menu item: 1 CIRCLE Radius: 40 Area: 5026.54 Bye!
Menu item: 2 SQUARE Height: 5 Area: 25 Bye!
Menu item: 3 RECTANGLE Height: 5 Width: 6 Area: 30 Bye!

Add a comment that simply says //fixed above each of the lines you fix. When you are done, you will submit the .cpp file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions