Help with program using switch statements to pass multiple functions

This is not the entire program, just the part I currently need help with, and the functions I am calling in this part.

I am returning area from areaCircle(), but do not know how to print it in main. I know this program has lots of errors, so I would appreciate it if someone would help with the two cases that I have listed.

Not sure how to properly list multiple function calls in a switch statement, and how to print one's return from main.

Thanks a ton!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int main()
{
	char choice;
	double area;

	showMenu(choice);

	switch (choice) // If input is C, use getRadius, areaCircle and count, then print the are 
	{
		case 'C': void getRadius(),double areaCircle(), void count(bool display = false);
			cout << "Area is "<< area << endl;
		case 'c': void getRadius(), double areaCircle(), void count(bool display = false);
			cout << "Area is " << area << endl;
			break;
	}


	system("pause");
	return 0;
}


1
2
3
4
5
6
7
8
9
10
11
12
void getRadius(double & radius)
{
	do
	{
		cout << "Enter radius ";
		cin >> radius;

		isNegative(radius);
	} 
	while (true == isNegative(radius));

}


1
2
3
4
5
6
7
double areaCircle(double radius)
{
	double area;
	area = PI*(radius*radius);

	return area;
}


1
2
3
4
5
6
7
8
9
10
11
12
bool isNegative(double val)
{
	if (val >= 0)
	{
		return false;
	}
	else
	{
		cout << "Entry was negative. Must be positive";
		return true;
	}
}


1
2
3
4
5
6
7
8
9
10
11
12
void count(bool display)
{
	static int count;
	if (display = false)
	{
		count++;
	}
	else
	{
		cout << "Counter is " << count << endl;
	}
}
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
switch (choice)
{
    case 'C': void getRadius(),double areaCircle(), void count(bool display = false);
        cout << "Area is "<< area << endl;
    case 'c': void getRadius(), double areaCircle(), void count(bool display = false);
        cout << "Area is " << area << endl;
        break;
    case 'c':
    case 'C': //Using fallthough
        getRadius(radius); //Calling function instead of declaring it
        area = areaCircle(radius); //Assigning result of callin funtion to area
        std::cout << "Area is "<< area << endl;
}

//...

while (true == isNegative(radius));
Also, I'm not sure what count() is for but it has a bug. It should be:
if (display == false) using == instead of =. Or better yet
if (!display)
Thank you guys so much! If I have further questions about this program is it better to start a new thread, or continue this one? I'm not sure how many people will check back if I update this one? Also, is there a way to up you guys' reputation or anything?
Last edited on
I'd continue on this thread.
You should continue on this thread.
Topic archived. No new replies allowed.