ok so two problems the first isn't a big deal because I'm slowly working it out (it is under the // basically need to give the user two chances to input correctly then close the program). The second is literally kicking my butt. I am able to output the calendar 80% correct except for the first line. Do i need to set the initial parameters to something different? because right now it seems to simply randomly place integers where it wants along the first line.
#include <iomanip>
#include <iostream>
usingnamespace std;
int main(void)
{
int week;
int month;
if ((month>=28||month<=31)&&(week>=1||week<=7))
{
cout << "Enter the number of days in the month: \n";
cout << "Enter day of week which month starts (Sun=1, Sat=7): \n";
cin >> month;
cin >> week;
// if((month<28||month>31)&&(week<1||week>7))
// {
// cout << "Enter a value in the range 28-31 and 1-7. \n";
// }
// if((month<28||month>31)&&(week<1||week>7))
// {
// cout << "ok so that is twice now and it is now going to close \n";
// }
// trying to get the second loop to work
}
cout << "\nSun Mon Tue Wed Thu Fri Sat\n";
for (int i =1; i<= week ; i++) // parameters for first week
{
cout << setw(3) << left << "";
}
for (week=1; week <= month; week++) // parameters for second week
{
cout << setw(4) << left << week << "";
if (((week+month-1)%7)==0)
{
cout << endl;
}
}
cout << endl;
cin.ignore();
return 0;
}
I guess i should mention I know this can be done with a switch case statement, I also know that it can be done without one I simply cannot figure it out, and I see no point in making 15 lines for something that can be done a better way.