Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need a C++ program that will allow me to enter a date and tell me what day of

ID: 674030 • Letter: I

Question

I need a C++ program that will allow me to enter a date and tell me what day of the week it is here is my code can you please fix it so it will work. it needs all the functions in it. it compiles fine but then when i go to run it theres nothing. just need it to run don't really care how

#include <iostream>
using namespace std;


// PROTOTYPES

bool isLeapYear(int year);
int getCenturyValue(int year);
int getYearValue(int year);
int getMonthValue(int month, int year);
void getInput (int& month, int& day, int& year);
int main()
{
// LOCAL DECLARATIONS
int month;
int day;
int year;
int dayOfWeek;
// PROCEDURES
void getInput (int& month, int& day, int& year);
dayOfWeek = getCenturyValue(year) + getYearValue(year) + getMonthValue(month, year) + day;
dayOfWeek %= 7;
switch (dayOfWeek)
{
case 1: cout << "Sunday"; break;
case 2: cout <<"Monday"; break;
case 3: cout <<"Tuesday"; break;
case 4: cout <<"Wednesday"; break;
case 5: cout <<"Thursday"; break;
case 6: cout <<"Friday"; break;
case 7: cout <<"Saturday"; break;
}
return 0;
}

//---------------------------------------------------------
// FUNCTION DEFINITIONS
//---------------------------------------------------------
void getInput(int& month, int& day, int& year)
        {
        cout << "Enter day: ";
        cin >> day;
        cout << "Enter month: ";
        cin >> month;
        cout << "Enter year: ";
        cin >> year;
        }

bool isLeapYear(int year)
        {
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
         return true;
         else
         return false;
         }


int getCenturyValue(int year)
         {
         int century = year / 100;
         return (3 - century % 4) * 2;
         }


int getYearValue(int year)
         {
         int yy = year % 100;
         return yy / 4 + yy;
         }


int getMonthValue(int month, int year)
         {
         if (month == 1)
         {
         if (isLeapYear(year))
         return 6;
         else
         return 0;
         }
         else if (month == 2)
         {
         if (isLeapYear(year))
         return 2;
         else
         return 3;
         }
         else if (month == 3)
         return 3;
         else if (month == 4)
         return 6;
         else if (month == 5)
         return 1;
        else if (month == 6)
        return 4;
        else if (month == 7)
        return 6;
        else if (month == 8)
        return 2;
        else if (month == 9)
        return 5;
        else if (month == 10)
        return 0;
         else if (month == 11)
        return 3;
        else if (month == 12)
        return 5;
        return -1;
}

Explanation / Answer


#include <iostream.h>
#include <conio.h>

//Main Function

int main()
{

int days,month,dd,mm,yy,num;
char ans,again;

do{
cout<<"Im Data Validator!Wanna Try me?! (Y/N) ";
cin>>ans;
}while(ans=='N'||ans=='n');

do{
cout<<"Enter Date: ";
cin>> dd;
}while (dd==1&&dd==31);

do{
cout<<"Enter Month: ";
cin>> mm;
}while (mm==1&&mm==12);

do{
cout<<"Enter Year: ";
cin>> yy;
}while (yy==0&&yy==num);


// Function

switch (mm){
case 1: case 3: case 5: case 7:case 8: case 10: case 12 : days=31;
break;
case 4: case 6: case9: case 11 : days=30;
break;
case 2 : if (yy%4==0)days=29;
else
days=28;
}

// Function

if (dd>=1&&dd<=days&&mm>=1&&mm<=month)
cout<<"Your Date is Valid!! ";
else
cout<< "Sorry Your Date is Invalid ";

do{
cout<<"Do you want to try it again? (Y/N)";
cin>>again;

}while (again=='N'||again=='n');


getch();

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote