Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write this C++ program, use else if statements if possible. I also believe there will also be cin and cout variables. Thank you!! Write
Please write this C++ program, use else if statements if possible. I also believe there will also be cin and cout variables. Thank you!!
Write a C++ program that, given a person's birth date (or any other date in the Gregorian calendar), will display the day of the week the person was born. To determine the day of the week, you will first need to calculate the day of the week for December 31 of the previous year. To calculate the day for December 31, use the following formula: ( 1 1-1m00 11+1"400 11) year - 1 year -1) x 365+ 96 7 The result of the formula is an integer in the range [0.6], where 0 is Sunday, 1 is Monday, 2 is Tuesday, and 6 is Saturday. Once you know the day for December 31, you simply calculate the days in the year before the month in question. Use a switch statement to make this calculation. (Hint: Use case 12 first, and then fall into case 11, 10, 2.) If the desired month is 12, add the number of days for November (30). If it is 11, add the number of days for October (31). If it is 3, add the number of days for February (28). If it is 2, add the number of days for January (31). If you do not use a break between the months, the switch will add the days in each month before the current month. To this figure, add the day in the current month and then add the result to the day code for December 31. This number modulo seven is the day of the week. There is one more refinement. If the current year is a leap year, and if the desired date is after February, you need to add 1 to the day code. The following formula can be used to determine if the year is a leap year. (Iyear 96 4) && (year 96 100))! ! (year % 400) Your program should prompt the user to enter a date in month, day, year order. Note the input format in the sample interaction below. If you detect input failure, print "Input failure." and return 1 from the main functionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started