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
|
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int largest(int num){
do { /* The function does not take any parameters. So, you can read all your input in the
function. It returns an int, which is the largest number to main. Use a loop to
read the numbers until the user enters -1 to quit. As you read, keep track of the
largest number. When the user enters -1, stop reading and return the largest
number to the main function. Do NOT use an array for this program. */
cout << "Please enter a number. Enter (-1) to quit: ";
cin >> num;
}while(num!= -1);
}
void numberCount(int number, int &oddCount, int &evenCount, int &zeroCount){
/* Write a function that takes as a parameter an integer, and returns the number of
odd, even and zero digits. This should be a void function since a function cannot
return 3 values*/
}
int main ()
{
int num, number, oddCount, evenCount, zeroCount;
char choice;
do {
cout << "Welcome to my progam!" << endl << endl;
cout << "Here are your following options:" <<endl;
cout << "(a) Find the largest list of positive numbers (-1) to quit" << endl;
cout << "(b) Given a positive number display the number of even, odd, and zero digits in the number" << endl;
cout << "(c) quit the program."<< endl;
cout << "Please enter your choice: ";
cin >> choice;
switch (choice){
case 'a':
largest(num);
break;
case 'b':
numberCount(int number, int& oddCount, int& evenCount, int& zeroCount);
break;
case 'c':
cout << "Thank you for using my program!" << endl;
return 0;
break;
}
}while(choice!='c');
}
|