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

Dec 19th, 2015
Anonymous
Category:
Programming
Price: $10 USD

Question 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;
}
}




Tutor Answer

(Top Tutor) shyamnair3
School: Purdue University

Studypool has helped 1,244,100 students

Review from student
Anonymous
" Outstanding Job!!!! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1831 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors