Hello. I'm new to C++ I need help with my homework.
here is what I have to do
Develop a flowchart and then write a menu-driven C++ program that uses several user-defined functions, overloaded functions, and references.
Upon program execution, the screen will be cleared and the menu shown below will appear at the top of the screen and centered. The menu items are explained below.
Help Smallest Largest Quit
H or h ( for Help ) option will invoke a function named help() which will display a help screen. The help screen(s) should guide the user how to interact with the program, type of data to be entered, and what results would the program produce. Each help screen should remain on the monitor until the user strikes any key. Once the user's input is processed, the screen will be cleared and the menu is displayed again.
S or s ( for Smallest ) option will invoke the function named smallest( ) which will prompt the user for the two floats and calls the function findSmallest() which will compute and return the smallest number in the set. Once the smallest number is found, the function display() will be called (from the smallest() function) and displays the inputted numbers and the smallest using the format shown below.
n1 = xxx.xx, n2 = yy.yy and smallest is zzz.zz
where n1 is the first number and n2 is the second number. x, y, and z are place holders for the actual numbers. Note that two significant digits are required after the decimal point.
The function prototypes to be used are:
void smallest(void);
float findSmallest(float f, float s);
void display(float& f, float& s, float& small);
where f refers to the first number and s refers to the second number.
The results should stay on the screen with the following prompt which will appear on the lower right hand corner of the screen:
Strike any key to continue...
Once the user entered a key, the screen will be cleared and the menu is displayed again.
L or l ( for Largest ) option will invoke the function named largst( ) which will prompt the user for the two doubles and calls the function findLargestt() which will compute and return the largest number in the set. Once the largest number is found, the function display() will be called (from the largest() function) and displays the inputted numbers and the smallest using the format shown below.
n1 = xxx.xxxx, n2 = yy.yyyy and largest is zzz.zzzz
where n1 is the first number and n2 is the second number. x, y, and z are place holders for the actual numbers. Note that four significant digits are required after the decimal point.
The function prototypes to be used are:
void largest(void);
double findLargest(double f, double s);
void display(double& f, double& s, double& large);
where f refers to the first number and s refers to the second number.
The results should stay on the screen with the following prompt which will appear on the lower right hand corner of the screen:
Strike any key to continue...
Once the user entered a key, the screen will be cleared and the menu is displayed again.
Note: display() is an overloaded function.
Q or q (for Quit) option will clear the screen and returns the control to the Visual Studio IDE.
This is what I have so far. I keep getting error messages LNK2019 and LNK1120
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
extern char menu(void);
extern void smallest(void);
extern void largest(void);
float findsmallest(float f, float s);
double findlargest(double f, double s);
extern void display (float f, float s);
extern void display (double f, double s);
int main(void)
{
int n1, n2;
float findsmallest (float f, float s);
char op;
while(1)
{
op = menu();
switch(op)
{
case 'h' :
case 'H' :
cout << "\t How to Operate Program\n"
<< "Select any of the menu items\n"
<< "h or H for Help\n"
<< "s or S for Smallest\n"
<< "Option will find the smallest number of two numbers\n"
<< "l or L for Largest\n"
<< "Option will find the largest number of two numbers\n"
<< "q or Q will terminate program\n";
case 'a' :
case 'A' :
cout << "\n\nPlease input values for n1 and n2,"
<< " (integer) only ==> ";
cin >> n1 >> n2;
findsmallest(n1, n2);
break;
case 'f' :
case 'F' :
cout << "\n\nPlease input values for n1 and n2,"
<< " (float) only ==> ";
cin >> n1 >> n2;
findlargest(n1, n2);
break;
}
}
return EXIT_SUCCESS;
}
extern char menu(void)
{
char menuOption;
int flag = 1;
while(flag == 1)
{
cout << "\th. Help\ts. Smallest\t\tl. Largest\t\tq. Quit\n\n\t\t\tmake"
<< " your selection ==> ";
cin >> menuOption;
switch(menuOption)
{
case 'h' :
case 'H' :
case 's' :
case 'S' :
case 'l' :
case 'L' :
flag = 0;
break;
case 'q':
case 'Q':
cout << "\nFinished..." << endl;
exit(0);
default :
cout << "\n\twrong choice, try again\n\n";
}
}
return menuOption;
}
|