This is a homework assignment. I have the code done so it will run correctly. I am struggling with using the toupper function though. I want to use it instead of using case 'a", case 'A' etc...
I am not sure where I place it or the exact way to code it. any pointers would be great.
CODE
#include<iostream>
#include<cctype>
using namespace std;
void LargestNum();
void SmallestNum();
int main()
{
char option;
do
{
cout << " A - Find the largest # with a known quantity of numbers.\n";
cout << " B - Find the smallest # with an unknown quantity of numbers.\n";
cout << " C - Quit!\n";
cout << endl;
cout << "Please enter your choice: ";
cin >> option;
cout << endl;
switch (option)
{
case 'A': LargestNum(); break;
case 'B': SmallestNum(); break;
}
} while (option != 'C');
system("PAUSE");
return 0;
}
void LargestNum()
{
int entry;
int i = 0;
int input;
int largest = 0;
cout << "How many numbers would you like to enter? ";
cin >> entry;
for (i = 0; i < entry; i++)
{
cout << "Number " << i+1 << ":";
cin >> input;
if (input > largest)
largest = input;
}
cout << endl;
cout << " The largest number you entered is: " << largest << "\n";
cout << endl;
}
void SmallestNum()
{
int smallest, input1 = 0, i1 = 1;
cout << endl;
cout << "Enter as many numbers as you want, when finished type -99\n";
cout << endl;
do
{
cout << "Number" << i1 << ": ";
cin >> input1;
i1++;
if ((input1 < smallest) && (input1 != -99))
smallest = input1;
} while (input1 != -99);
cout << endl;
cout << " The smallest number you entered is: " << smallest << "\n";
cout << endl;
}
This post has been edited by rttlsnake: 16 Feb, 2008 - 09:35 PM