i'm completely new at this and would appreciate all the help i can get. there's no year needed, justa simple output of the following months in a grid like format. Here's what i have so far:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void printmonth(const int month, const int startday, const bool leap);
int main(void)
{
printmonth(1,0,false); // Print January 1st, on a Sunday
printmonth(2,1,true); // Print February 1st leap year, on Monday
printmonth(1,2,false); // Print January 1st, on a Tuesday
printmonth(2,3,false); // Print February 1st not leap, on Wednesday
printmonth(1,4,false); // Print January 1st, on a Thursday
printmonth(2,5,false); // Print February 1st, on a Friday
printmonth(1,6,false); // Print January 1st, on a Saturday
printmonth(6,1,false); // Print June 1st, on Monday
printmonth(12,4,false); // Print December 1st, on a Thursday
return 0;
}
void printmonth(const int month, const int startday, const bool leap)
Start with a sample output that you would expect as precisely as you can. This little exercise is more for your benefit.
Advice: whenever you have a new problem to solve, start with first creating a sample output and then jot down the "logic" that you would use to solve that problem. Typing out the solution to the problem into your computer should be the last thing you do.
I was told to use 2 arrays and 2 for loops. This is the shell i was given:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void printmonth(const int month, const int startday, const bool leap);
int main(void)
{
printmonth(1,0,false); // Print January 1st, on a Sunday
printmonth(2,1,true); // Print February 1st leap year, on Monday
printmonth(1,2,false); // Print January 1st, on a Tuesday
printmonth(2,3,false); // Print February 1st not leap, on Wednesday
printmonth(1,4,false); // Print January 1st, on a Thursday
printmonth(2,5,false); // Print February 1st, on a Friday
printmonth(1,6,false); // Print January 1st, on a Saturday
printmonth(6,1,false); // Print June 1st, on Monday
printmonth(12,4,false); // Print December 1st, on a Thursday
return 0;
}
okay this is what i have so far. but the dashes are not in the right spot. how do i get them where the empty days are?
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void printmonth(const int month, const int startday, const bool leap);
int main(void)
//comments
{
printmonth(1,0,false); // Print January 1st, on a Sunday
printmonth(2,1,true); // Print February 1st leap year, on Monday
printmonth(1,2,false); // Print January 1st, on a Tuesday
printmonth(2,3,false); // Print February 1st not leap, on Wednesday
printmonth(1,4,false); // Print January 1st, on a Thursday
printmonth(2,5,false); // Print February 1st, on a Friday
printmonth(1,6,false); // Print January 1st, on a Saturday
printmonth(6,1,false); // Print June 1st, on Monday
printmonth(12,4,false); // Print December 1st, on a Thursday
return 0;
}
void printmonth(const int month, const int startday, const bool leap)
{
//define arrays
//declare three variables?
string monthArray[13]= {"null", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
int daysArr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//check leap year
//You already decleared the variables at the top of the function in the "()". So you don't need to declear it again
//by saying 'int' 'bool'.
if (leap==true && month== 2)
{daysArr[2]=29;
}
//print out month/ week
//for loop comes in when to stop printing numbers