please help Calendar- stars around a day

if the user puts choice to equal two i have figured out how to make that month and the proper day show up. Now i cant figure out how to put stars around a certain date that the user inputs, could someone please help me

ex. 1 2 *3* 4 5 6 7
-----------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

/* Function Prototype */
string NameMonth (int Month);

/* Function Prototype */
int DaysYear (int Year);

/* Function Prototype */
int DaysMonth (int Month, int DaysYear);

/* Function Prototype */
int LastDayInYear (int Year);

/* Function Prototype */
int FirstDayInYear (int Year);

/* Function Prototype */
void Spacing (int FirstDay);

/* Function Prototype */
void spaceToDay (int d);

/* Function Prototype */
void printMonth (int DaysInMonth, int FirstDay);

/* Function Prototype */
void printHeader (string NameOfMonth, int Year);

/* Main Program */
int main()
{
int Month, Year, DaysInYear, LastDay, FirstDay, DaysInMonth, PrintMonth, PrintHeader, Choice, day;

cout << "Enter the year: ";
cin >> Year;

DaysInYear = DaysYear(Year);
FirstDay = FirstDayInYear (Year);
LastDay = LastDayInYear(Year);

cout << "Year calendar (1) Special Day (2): ";
cin >> Choice;

if (Choice == 1){
Month = 1;
while (Month < 13){
DaysInMonth = DaysMonth(Month, DaysInYear);
string NameOfMonth = NameMonth(Month);
printHeader (NameOfMonth, Year);
printMonth (DaysInMonth, FirstDay);
cout << endl << endl << endl;
FirstDay = (FirstDay + DaysMonth(Month, DaysInYear)) %7;
Month = Month + 1;
}
}
else if (Choice == 2){
cout << "Month: ";
cin >> Month;
cout << "Day: ";
cin >> day;

DaysInMonth = DaysMonth(Month, DaysInYear);
FirstDay = ((FirstDay + DaysMonth(Month, DaysInYear)) %7) - 1;
string NameOfMonth = NameMonth(Month);
printHeader (NameOfMonth, Year);
printMonth (DaysInMonth, FirstDay);


}
}

/* Function: NameMonth
* Usage: NameMonth(Month)
* ------------------------
* It allows the user to input what month they are looking
* for by assignning a number to a month. The program
* will return the month that is beside the true case.
*/

string NameMonth (int Month)
{
switch (Month){
case 1 : return "January" ;break;
case 2 : return "Feburary" ;break;
case 3 : return "March" ;break;
case 4 : return "April" ;break;
case 5 : return "May" ;break;
case 6 : return "June" ;break;
case 7 : return "July" ;break;
case 8 : return "August" ;break;
case 9 : return "September" ;break;
case 10: return "October" ;break;
case 11: return "November" ;break;
case 12: return "December" ;break;
default : return "not a case";
}
}

/* Function: DaysYear
* Usage: DaysYear (Year)
* ------------------------
* it will take the year and will check if it matches
* one of the two statements, if it divides evenly into
* 4 and 100 or if it evenly divides into 400 and 100.
* if it is yeas to either it is a leap year, if it
* doesnt then there is only 365 days in that year
*/

int DaysYear (int Year)
{
if ((Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0 && Year % 100 == 0)) return 366;
else return 365;
}

/* Function: DaysInMonth
* Usage: DaysInMonth ( Month, DaysInYear)
* ------------------------
* it checks to see the numner that the month is,
* it then will go to find out how many days there
* are in that month by checking the value entered
* for set month. it will check if it is a leapyear
* because that will change number of days in feb.
*/

int DaysMonth (int Month, int DaysInYear)
{
if(Month == 1) return 31;
else if (Month == 2 && DaysInYear == 365) return 28;
else if (Month == 2 && DaysInYear == 366) return 29;
else if (Month == 3) return 31;
else if (Month == 4) return 30;
else if (Month == 5) return 31;
else if (Month == 6) return 30;
else if (Month == 7) return 31;
else if (Month == 8) return 31;
else if (Month == 9) return 30;
else if (Month == 10) return 31;
else if (Month == 11) return 30;
else if (Month == 12) return 31;
else return 0;
}

/* Function: LastDayInYear
* Usage: LastDayInYear (Year)
* ------------------------
* it does the equation posted under,tp check
* out of the 7 days what one the last day will
* fall under
*/
int LastDayInYear (int Year)
{
int LastDay = (Year * 365 + Year/4 - Year/100 + Year/400 ) % 7; return LastDay;
}

/* Function: FirstDayInYear
* Usage: FirstDayInYear (Year)
* ------------------------
* it calculates the number of the first day of
* the year and returns it back to main
*/
int FirstDayInYear (int Year)
{
int FirstDay = (Year + (Year - 1)/4 - (Year - 1)/100 + (Year -1)/400 ) % 7; return FirstDay;
}
/* Function:
* Usage:
* ------------------------
*
*/
void Space (int FirstDay)
{
while (FirstDay > 0) {
cout << " ";
FirstDay = FirstDay - 1;
}
}

/* Function:
* Usage:
* ------------------------
*
*/
void spaceToDay (int d){
return Space(3*d);
}

/* Function:
* Usage:
* ------------------------
*
*
*
*/
void printMonth (int DaysInMonth, int FirstDay) {
int day = 1;
spaceToDay(FirstDay);
while (day <= DaysInMonth) {
cout << setw(5) << day << " ";
if (FirstDay == 6){
cout << endl;
FirstDay = 0;
}
else FirstDay = FirstDay + 1;
day = day + 1;
}
}

void printHeader (string NameOfMonth, int Year)
{
cout<< setw(1) << NameOfMonth
<< setw(34) << Year
<< endl;

cout<< setw(3) << "Sun" << setw(6) << "Mon" << setw(6) << "Tues" << setw(6)
<< "Wed" << setw(8) << "Thurs" << setw(6) << "Fri"<< setw(6) << "Sat"
<< endl;
}
Last edited on
I'm sorry but I don't want to read unformated code.

Please use code tags.
http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.