display even, odd and zero digits

I have an assignment that I am stumped on. It compiles fine but when I run it the program doesn't read back the numbers. This is the assignment:

Write functions to do the following. Do not change the function signature. Please write the functions, using the given function signature and specifications. Finally write the main program to test the functions using a menu.
Write a function that reads positive numbers from the user, and returns the largest number and outputs it. The function signature should be
int largest();
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.
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. Here is your function signature:
void numberCount(int number, int &oddCount, int &evenCount, int &zeroCount);
So, if the user enters 34873045, the number of odd digits is 4, even digits is 3, and
zeros is 1. You must use integers, do not use strings.
The main function must display a simple menu as follows:
Welcome to my program! Please choose one of the following:
(a) Find the largest of a list of positive numbers (-1 to quit).
(b) Given a positive number, display the number of even, odd and zero digits in
the number.
(c) quit this program.
Based on what the user picks, use a switch or an if statement and output the corresponding answer. This menu should be in a loop so it continues to display after each turn until the user enters ā€˜cā€™ to quit.

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
#include <iostream>
#include <string> 
#include <iomanip>
#include <fstream>

using namespace std;



int largest(int num){
	
	do { 
		cout << "Please enter a number. Enter c to quit: ";
		cin >> num;
		
	}while(num!= -1);
	
}

void numberCount(int number, int &oddCount, int &evenCount, int &zeroCount){
}

int main ()
{
         cout << "Welcome, this program will!" << endl << endl;
	     cout << "(a) Find the largest list of positive numbers." << endl;
		 cout << "(b) From positive numbers will display the number of even, odd, and zero digits in the number" << endl;
		 cout << "(c) when finished entering numbers enter -1."<< endl;
         cout << "(c) c quits the program."<< endl;
	int num, number, oddCount, evenCount, zeroCount;
	char choice;
	do {
        cout << "Please enter a number. Enter (-1) to after entering final number: ";
		cin >> choice;
		
        
			switch (choice){
			case 1:
				largest(num);
				break;
			case 2:
				numberCount(number, oddCount, evenCount, zeroCount);
				cout <<"The Numbers are" <<std::cin.get();
				break;
			case 3:
			cout  << "Thank you!" << endl;
			break;	
		}
	}while(choice!='c');
	return(0);
	system("PAUSE");
}

Last edited on
I would re-read the assignment instructions if I were you.

main() is simply supposed to loop over a menu and call the appropriate function based on the user's decision.

largest() is it's own function where you are doing some of main()'s work for some reason???

numberCount() is the trickiest, and my clue is to use division by 10 to check the number in the one's position.

Best of luck!
It's impossible to tell what you are really asking. What numbers do you want it to read back? What exactly is not working?
Topic archived. No new replies allowed.