Need help with computer science and loop in c++ based on input

User Generated

avpbyrehf

Computer Science

Description

I need some correction in final step printing the last part. For some reason the middle part of the program does not apply in the end...


int main(){
int year, month, days;

cout << "Enter month (1-12): ";
cin >> month;

cout << "Enter year (1990-): ";
cin >> year;

static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
int y = year - (month < 3);
int dayOfWeek = (y + y/4 - y/100 + y/400 + t[month-1] + 1) % 7;

switch(month){
  case 1: cout << "January "; break;  case 2: cout << "February "; break;  case 3: cout << "March "; break;  case 4: cout << "April "; break;
  case 5: cout << "May "; break;  case 6: cout << "June "; break;  case 7: cout << "July "; break;  case 8: cout << "August "; break;
  case 9: cout << "September "; break; case 10: cout << "October "; break;  case 11: cout << "November "; break; case 12: cout << "December ";
  cout << month << endl;
  }
cout << year << endl;
cout << "Mon  Tue  Wed  Thu  Fri  Sat  Sun" << endl;

if(month > 0 && month < 13){
  while(month > 0){
  }
}
else{
  cout << "Error." << endl;
}
}




User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Just what I was looking for! Super helpful.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags