Using c++ Write the program to calculate the day of the week of birth. This program should use a SWITCH instruction. The day, month and year of birth should be input. Based on these inputs the day of the week of birth is calculated as follows: a. Divide the last two digits of the birth year by 4. Put the quotient (ignoring the remainder) in TOTAL. For example, if the person was born in 83, divide 83 by 4 and store 20 in TOTAL. b. Add the last two digits of the birth year to TOTAL. TOTAL now contains 103. c. Add the last two digits of the birth date to TOTAL. If born on May 10, add 10. TOTAL now contains 113. d. Using the following table, find the "month number" and add to TOTAL. January = 1 February = 4 March = 4 April = 0 May = 2 June = 5 July = 0 August = 3 September = 6 October = 1 November = 4 December = 6 In our example: TOTAL now contains 115. e. If the year is leap year and if the month you are working with is either January or February, then subtract 1 from the total. TOTAL now contains 115. Which years are leap years? In the Gregorian calendar, which is the calendar used by most modern countries, the following rules decides which years are leap years: Every year divisible by 4 is a leap year. But every year divisible by 100 is NOT a leap year Unless the year is also divisible by 400, then it is still a leap year. f. Century Code adjustment. In my example Total will remain 115 because 1983 is in the 1900s. Total += 0 1700s = add 4 to total 1800s = add 2 to total 1900s = add 0 to total 2000s = add 6 to total 2100s = add 4 to total 2200s = add 2 to total 2300s = add 0 to total The formula below will add the correct value for each Century. A = (Year / 100) % 4; Total += 6 - (2 * A); g. Find the remainder when TOTAL is divided by 7. Look up the remainder in following table to determine the day of the week the person was born on. Note that you should not use this procedure if a person's birth year is earlier than 1900. TOTAL = 115, TOTAL / 7 = 3. Therefore May 10, 1983 was a Tuesday. 1 = Sunday 2 = Monday 3 = Tuesday 4 = Wednesday 5 = Thursday 6 = Friday 0 = Saturday Example Input: Input Month: 5 Input Day: 10 Input Year: 1983 Example output: A person born on May 10, 1983 was born on a Tuesday
Using c++
-
Write the program to calculate the day of the week of birth. This program should use a SWITCH instruction. The day, month and year of birth should be input. Based on these inputs the day of the week of birth is calculated as follows:
a. Divide the last two digits of the birth year by 4. Put the quotient (ignoring the remainder) in
TOTAL. For example, if the person was born in 83, divide 83 by 4 and store 20 in TOTAL.
b. Add the last two digits of the birth year to TOTAL. TOTAL now contains 103.
c. Add the last two digits of the birth date to TOTAL. If born on May 10, add 10. TOTAL now
contains 113.
d. Using the following table, find the "month number" and add to TOTAL.
January = 1
February = 4
March = 4
April = 0
May = 2
June = 5
July = 0
August = 3
September = 6
October = 1
November = 4
December = 6
In our example: TOTAL now contains 115.
e. If the year is leap year and if the month you are working with is either January or February, then
subtract 1 from the total. TOTAL now contains 115.Which years are leap years?
In the Gregorian calendar, which is the calendar used by most modern countries, the following rules decides which years are leap years:
- Every year divisible by 4 is a leap year.
- But every year divisible by 100 is NOT a leap year
- Unless the year is also divisible by 400, then it is still a leap year.
f. Century Code adjustment. In my example Total will remain 115 because 1983 is in the 1900s. Total += 0
- 1700s = add 4 to total
- 1800s = add 2 to total
- 1900s = add 0 to total
- 2000s = add 6 to total
- 2100s = add 4 to total
- 2200s = add 2 to total
- 2300s = add 0 to total
The formula below will add the correct value for each Century.
A = (Year / 100) % 4;Total += 6 - (2 * A);
g. Find the remainder when TOTAL is divided by 7. Look up the remainder in following table to determine the day of the week the person was born on. Note that you should not use this procedure if a person's birth year is earlier than 1900. TOTAL = 115, TOTAL / 7 = 3. Therefore May 10, 1983 was a Tuesday.
1 = Sunday
2 = Monday
3 = Tuesday
4 = Wednesday
5 = Thursday
6 = Friday
0 = Saturday
Example Input:
Input Month: 5
Input Day: 10
Input Year: 1983Example output:
A person born on May 10, 1983 was born on a Tuesday.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images