Start with your first function,
oz_to_cups()
Since you'll want it to
return
a value, let's make it
int oz_to_cups(double ounce)
In there, you will take
ounce
and do the math to make it a cup, which should be a pretty simple step. After you've got that down, at the bottom of the function write,
return ounce
(Remember! You have to define your function before
main
in order for it to work.)
After that, setup
int cups_to_pints(double cups)
Steps 4 and 5...? I don't mean to sound stupid, but what do you mean by
?
As for the loop, I'd suggest a while loop, which you can read more about here.
http://www.cplusplus.com/doc/tutorial/control/
You'll need a variable, for example...
bool whileTrue
in order for the loop to run. Make sure that
whileTrue
becomes
false
, or else you'll be stuck in an infinite loop.
In that loop, you'll have
cout<<"Welcome to my conversion program. Would you like to convert ounces to cups?"<<"Enter y(yes) or n(no)";
Get the input, and use an if statement to check. If you don't want it to be case sensitive, you could convert all the characters in the string to uppercase (or lowercase) that way you don't have to worry about case sensitivity. Otherwise, using an
||
(or) operator could work just fine.
1 2 3 4
|
if (userinput == "yes" || userinput == "YES")
{
// Get input again. Send that input to oz_to_cups()
}
|
Do the same process when asking if the user wants to convert cups to pints
I tried to be vague so that you had some room to figure stuff out yourself, but if I was too vague my apologies! There are a few extra steps you could take to make the program more efficient but since it's not specified to do so in the directions, don't worry about it.
If you want me to take a look at your code once you've got it all down, or if something doesn't make sense I wouldn't mind helping at all:)