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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education