/*******************************************************/
// R.A. Hillyard
// funDevelopProcess2.cpp
// October 2001
//
// See funDevelopProcess1.cpp for project specs.
//
// The second stage implements the function stubs - here we just
// write a shell for the function body. We want to verify the values
// sent to the function and the return values. These are called function stubs
//
// When we have the stubs working we are ready to implement the functions
/*******************************************************/
#include<iostream>
using namespace std;
//function prototypes
char printMenu(); //print menu of choices
int min(int a, int b); //returns min of a and b
double max(double x, double y); //returns max of x and y
void printLine(char ch, int count); //print count characters
int main()
{
char choice; //for user choice
while(true) //run program until user chooses to quit
{
choice = printMenu(); //print menu - get choice
if(choice == 'Q') //if quit - break out of loop
break;
else if(choice == 'S') //else - call function to handle user request
{
int returnVal = min(5, 8);
cout << "min returned: "<< returnVal << endl;
}
else if(choice == 'L')
{
double returnVal = max(88.7, 55.345);
cout << "max returned: "<< returnVal << endl;
}
else if(choice == 'P')
{
printLine('X',25);
cout << "returned from printLine\n";
}
}//end while true
return 0;
}//end main
/*******************************************************/
// printMenu - prints the menu of choices checks for valid input and
// returns the upper case version of the user choice as a char variable
/*******************************************************/
char printMenu()
{
char ch; //this variable is local to the function
do
{
cout << "\nWelcome to Function Developmen\n";
cout << "------------------------------------\n";
cout << "Choose one of the following\n";
cout << " S Find the smaller of two ints\n";
cout << " L Find the largest of two doubles\n";
cout << " P Print a Number of Characters\n";
cout << " Q To quit\n\n";
cout << "Enter your choice: ";
cin >> ch;
ch = toupper(ch);
}while(ch != 'S' && ch != 'L' && ch != 'P' && ch != 'Q');
return ch;
}
/*******************************************************/
/*******************************************************/
// min - will return the smaller of two ints
// under construction
/*******************************************************/
int min(int a, int b)
{
//comment out when done testing
cout << "In function min: a = " << a << " b = " << b << endl;
return -99; //just a dummy value for now
}//end min
/*******************************************************/
// max - will return the larger of two doubles
// under construction
/*******************************************************/
double max(double x, double y)
{
//comment out when done testing
cout << "In function max: x = " << x << " y = " << y << endl;
return -99.99; //just a dummy value for now
}//end max
/*******************************************************/
// printLine - will print count ch's to the screen
/*******************************************************/
void printLine(char ch, int count)
{
cout << "In function printLine: ch = "
<< ch << " count = " << count << endl;
}
/********************Program output*****************
Welcome to Function Developmen
------------------------------------
Choose one of the following
S Find the smaller of two ints
L Find the largest of two doubles
P Print a Number of Characters
Q To quit
Enter your choice: s
In function min: a = 5 b = 8
min returned: -99
Welcome to Function Developmen
------------------------------------
Choose one of the following
S Find the smaller of two ints
L Find the largest of two doubles
P Print a Number of Characters
Q To quit
Enter your choice: L
In function max: x = 88.7 y = 55.345
max returned: -99.99
Welcome to Function Developmen
------------------------------------
Choose one of the following
S Find the smaller of two ints
L Find the largest of two doubles
P Print a Number of Characters
Q To quit
Enter your choice: P
In function printLine: ch = X count = 25
returned from printLine
Welcome to Function Developmen
------------------------------------
Choose one of the following
S Find the smaller of two ints
L Find the largest of two doubles
P Print a Number of Characters
Q To quit
Enter your choice: q
*/