passsing array and validating

Hi guys, can someone help me out on solving this problem below? I'm stuck on how
to set up the while loop to exit when the user enters zero for months. I also have no idea how to compare the day of each date, to validate it by looking up in the number of days array for the maximum number of days in the given month.
details:
Define a local array of 10 integers for months and another local array of 10 integers for days to be used to store 10 days read from the user. Also, define a local array of 12 integers, each representing each of the 12 months of the year and assign to them the number of days in each month, as follows: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, for January, February, March, etc.

Pass the array holding number of days of the months and the two arrays of months and days to a procedure which reads up to a maximum of 10 dates in mm/dd format, storing months in the array of months and days in the array of days. The user will enter as many dates as desired, up to a maximum of 10. When done, he or she will enter 0 for the month. As the user enters the day of each date, the program will validate it by looking up in the number of days array for the maximum number of days in the given month; if larger than the maximum, it will print an error message and read a new day value until it's valid for the given month. You need not worry about leap years. Show the user how to enter the dates; e.g.: 5/31 or 5 / 31 or 5 31.

Once all dates - as many as the user wants, up to a maximum of 10 - have been entered, pass the arrays of months and days and its size to a procedure called display to print all entered dates.

Use only local variables. Use extensive comments. Also, write your name on top as a comment.




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
#include <iostream>
using namespace std;
void prodedure(int number_days_of_months[], int days_month, int days[], int size_days, int months[], int months_size);

int main()
{

	int months[10]; //stores the month enter by the user 
	int days[10];   //stores the days enter by the user
	int number_days_of_months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //representing each of the 12 months of the year 




	prodedure(number_days_of_months, 12, days, 10, months, 10);






	return 0;
}



void prodedure(int number_days_of_months[], int days_month, int days[], int size_days, int months[], int months_size)
{

	// this procedure reads up to 10 days 
	// user will enter 10 days or till she wants but less than 10 

	
	
		while (months != 0)
		{


			for ( int i = 0; i < 10; i++)
			{



				cout << "enter a month" << endl;
				cin >> months[i];
				

			}
		}

		
}








void  display()
{







}
Last edited on
Topic archived. No new replies allowed.