i'm trying to run a program that calculates the surface area of various shapes. right now i only have it set it up through a sphere, but i can't go further until i figure this out. part of the assignment is that i must use the function "int getValue (string prompt, lowerBound, upperBound". so when this function is used, it will enter some words, in this case, something like "enter the radius of the sphere, and then there are limits as to how small and how large the radius can be. 2-15, let's say. anything outside that range is invalid and the user needs to be asked to try again. i've tried implementing this function a few different ways but it keeps being skipped completely. here is my code (i'm focusing on this function, not worried about the neatness of the rest of the code right now)
so i want the getValue function, when the user enters 1 for choice, to prompt them to enter the radius, and then have to enter one between 2 and 15. but when i run this, it runs the menu function fine, then skips the get value, and goes to calcSphere, where i can enter a number (without any prompting though) and it calculates it fine. i don't understand the purpose of the getValue function and it seems like it's unnecessary to me, but i have to use it. any advice on how to get it to work?
using namespace std;
const double PI = 3.14159;
int value,choice, radius;
int menu(int choice)
cout<<"\nSurface Area Calculator"
<<"\n3) Rectangular Prism"
<<"\n\nEnter Your Choice: ";
while (choice<1 || choice>5)
cout<<"\nInvalid choice, please try again";
float calcSphere (int radius)
cout<<"The surface area of the sphere is"<<surface_area_sphere;
int getValue (string prompt, int lowerBound, int upperBound)
getValue ("Enter the radius of the sphere", 2,15);
calcSphere (radius) ;