Day Calculation Background - Many times one needs to do calculations on dates. Programs like Excel use the number of days since 1/1/1970 when doing these calculations. We don't know enough C++ to completely do this calculation, yet, but we can make a start. Problem - You will prompt a user for a month, a day and a year. You will then tell the user how many days since January 1 of that year the input date is. For example if the user inputs a 3 for the month, a 2 for the day, and 2000 for the year the program outputs the number of days as being 62. Note 2000 is a leap year. Therefore you must test to see if a year is a leap year when doing this problem. The three rules which the Gregorian calendar uses to determine leap year are as follows: 1. Years divisible by four are leap years, unless... 2. Years also divisible by 100 are not leap years, except...** 3. Years divisible by 400 are leap years. ** ** Combining rules 2 & 3: Centennial years that are not divisible by 400 are not leap years. **Another way of looking at the definition of a leap year: Leap years fall on any year that either can be evenly divided by 400 or evenly divided by 4 and not evenly divided by 100. Therefore the years 1900, and 2100 are NOT leap years. Method - Use if - else statements to decide: 1. How many days to add given the month 2. Whether to add an additional day for leap year. 3. Don't forget to add in the days for the current date within a month Ex. if the user inputs month = 4, day = 22, year = 1995 Since 1995 is not a leap year add 90 days (total for January, February, and March) then to that add 22 for the number of days in April for a total of 112 days. Output - Organize your prompts, and output in a neat orderly fashion. Print a statement telling whether the year is a leap year and another statement about the number of days since January 1 of that year has past. Turn In – Your source code and 3 valid examples (pick ones that are/are not leap years) showing that your program works.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 28PE
icon
Related questions
Question

Lab #3 – Day Calculation
Background - Many times one needs to do calculations on dates. Programs like Excel use the number of days since 1/1/1970 when doing these calculations. We don't know enough C++ to completely do this calculation, yet, but we can make a start.
Problem - You will prompt a user for a month, a day and a year. You will then tell the user how many days since January 1 of that year the input date is.
For example if the user inputs a 3 for the month, a 2 for the day, and 2000 for the year the program outputs the number of days as being 62. Note 2000 is a leap year. Therefore you must test to see if a year is a leap year when doing this problem.
The three rules which the Gregorian calendar uses to determine leap year are as follows:
1. Years divisible by four are leap years, unless...
2. Years also divisible by 100 are not leap years, except...**
3. Years divisible by 400 are leap years. **
** Combining rules 2 & 3: Centennial years that are not divisible by 400 are not leap years.
**Another way of looking at the definition of a leap year:
Leap years fall on any year that either can be evenly divided by 400 or evenly divided by 4 and not evenly divided by 100.
Therefore the years 1900, and 2100 are NOT leap years.
Method - Use if - else statements to decide:
1. How many days to add given the month
2. Whether to add an additional day for leap year.
3. Don't forget to add in the days for the current date within a month
Ex. if the user inputs month = 4, day = 22, year = 1995
Since 1995 is not a leap year add 90 days (total for January, February, and March) then to that add 22 for the number of days in April for a total of 112 days.
Output - Organize your prompts, and output in a neat orderly fashion. Print a statement telling whether the year is a leap year and another statement about the number of days since January 1 of that year has past.
Turn In – Your source code and 3 valid examples (pick ones that are/are not leap years) showing that your program works.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr