0

This is the final homework assignment for a class I'm in. I'm not asking for answers, really, just something to get me pointed in the right direction (I don't want to cheat myself out of learning).

I need to create a calendar using a 2 dimensional array along with a parallel array to output a calendar based on user input.

  1. Declare month to be an array of type int of the proper size and dimensions (weeks and days), and initialize all elements to 0.
  2. Handle user input as follows: a. Ask the user for the month name, and match it to the appropriate number of days (hint: use parallel arrays) b. If the month is February, you need to know the year, and test if it is a leap year to adjust February’s number of days, if needed. c. Ask the user which day of the week the month starts on, and match it to the proper day number (Sunday being day 1), to determine which position in the two-dimensional array to start storing dates (hint: use parallel arrays)
  3. Use formatted output to display the month left-aligned, omitting “0” dates (see the output example below)
  4. Use functions if desired. Allow your main program to loop, allowing the user to ask for an unlimited number of months. Blockquote

I am not sure how to even really begin to start this. What should my array look like? Do I need to create a function for every month? How would I load the data into the array based on the user input? This is all I have right now:

int main(){

int month[6][7],rows,col;
string days[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int year;
string userInput = " ";

cout << "Enter a month: ";

for (int r = 0; col < 5; r++)
{


}
}

Keep in mind this is low level C++ programming, so advanced concepts haven't really been introduced yet.

I appreciate any help you guys offer, thanks!

brettsalyer
  • 57
  • 1
  • 9
  • Just start somewhere, experiment. Any code is better than no code. Once you have something (possibly with a list of compiler errors) you could ask a more concrete question. – 463035818_is_not_an_ai Nov 25 '16 at 13:48
  • ...btw "and this is due soon" doesnt make your question more appealing. SO is not a "do my homework, because I need it asap" platform, but it is about concrete programming problems. – 463035818_is_not_an_ai Nov 25 '16 at 13:51
  • @tobi303 I was simply stating why I came here in the first place. I wanted to use it as a last resort. I was not trying to get anyone to do my homework for me. I merely wanted pointed in the right direction. I wasn't relying on SO to get my project done. I posted so that I may have answers to fall back on. Because right now I am pretty clueless, and I couldn't find any similar questions. I'll take it down now. – brettsalyer Nov 25 '16 at 13:59
  • I didnt want to offend you, but rather help you to improve the question. At the moment it is just too broad. We dont know on what level you are, so we cannot know what needs to be explained. Once you provide a piece of code it will be so much easier to help – 463035818_is_not_an_ai Nov 25 '16 at 14:03
  • @tobi303 I updated what I have so far. I'm compiling on Linux, so its harder to continuously "guess and check". It's not much, but I'm not even sure what to try. – brettsalyer Nov 25 '16 at 14:09
  • first of all: it looks like you have a `using namespace std;` (that you dont show here), [dont use that](http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice). I dont see anything wrong with the array and to read the numbers you can use `std::cin` – 463035818_is_not_an_ai Nov 25 '16 at 14:22
  • Huh, I did not realize that was bad practice. So its better to just do something like `std::cout` or `std::cin`? Thanks for that, I did not realize. – brettsalyer Nov 25 '16 at 14:27
  • depends what you like better. I personally prefer to write `std::cout` , but you could also `using std::cout;` – 463035818_is_not_an_ai Nov 25 '16 at 14:48

0 Answers0