Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

okay so im working on a C++ lab and i need to follow this flow chart. im working in visual studio 2013 and i encounter

okay so im working on a C++ lab and i need to follow this flow chart. im working in visual studio 2013 and i encounter a problem where it claims the variable "triangle" isnt being defined. when i type in "t" for triangle calculations. im not sure what this means or how to fix it and was hoping for some guidence. image text in transcribed
image text in transcribed
the code so far.
#include
#include
#include
#define _CRT_SECURE_NO_WARNINGS
/*******************************************************************************
LAB 5: Swtich statements
********************************************************************************
Developed by:
Date: Feb 9, 2020
********************************************************************************
Description: Using switch statements in programs
*******************************************************************************/
//ProtoType
float calcArea(char shape);
float GetDim_Base(char triangle);
/*******************************************************************************
Main
*******************************************************************************/
float main()
{
//variable Declarations
char shape;
float area;
//Describe program operation
printf("This program will calcualte the area of three diffrent shapes: ");
printf(" a Traingle, circle, and a Rectangle. ");
//Get shape
do
{
printf("please enter 't' for triangle, 'r' for Rectangle or 'c' for Circle: ");
fflush(stdin);
shape = getchar();
switch (shape)
{
case 't':
case 'T':
printf("you have chosen to calculate a triangles area. ");
break;
case 'R':
case 'r':
printf("you have chosen to calculate a Rectangles area. ");
break;
case 'c':
case 'C':
printf("You have chosen to calculate a Circles area. ");
break;
default:
printf("invalid selection please try again with either 'r' 'c' or 't': ");
break;
}
} while (shape != 't' && shape != 'c' && shape != 'r');
//function call
area = calcArea(shape); //go to Calculate area function
while (!_kbhit()); //keeps window open until keybored is pressed.
}
float calcArea(char shape)
{
//Declare variables
float tri;
char triangle;
//char square;
//char circle;
switch (shape)
{
case 't':
case'T':
tri = GetDim_Base(triangle);//this is where yoru problems are so far
break;
case 'r':
printf("test2");// to check if its calling to functions correctly.
break;
case 'c':
printf("test3");
break;
default:
printf("....");
}
return shape;
}
float GetDim_Base(char triangle)
{
printf("testerrrrr"); //using these to tell me if its call to the function correctly
return triangle;
}
( Calcarea to out Calculate Area Declare Variables Triangle Yes

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions