My task is to accept user input for a date in the format "dd mm" and then use the day and month to do calculation with array.
The julian format should be calculated i.e the day of the year the 'dd mm' represents which is how many days has passed since "01 01".
The array is int daysPerMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; So if '27 03' is entered then the julian format of that date is 31 + 28 + 27 = 86.
I am having trouble with using the string as input by the user in the int array calculation. I am not even sure if my method is possible. Wondering if there is some kind of conversion function or typecasting method. My attempted below.
cout << "Enter the first date (in the format of 'dd mm') : ";
getline (cin, date1);
cout << "Enter the second date (in the format of 'dd mm') : ";
getline (cin, date2);
cout << endl << "Juian format of date 1 is " << finalJulianDate1 << endl << endl;
cout << "Juian format of date 2 is " << finalJulianDate2 << endl << endl;
cout << "Days passed between the two dates are " << std::abs(daysCalc) << endl;