Question: Part 2 use c + + not python or java Overview When working with extremely distant celestial objects, astronomers have to work not in hours

Part 2 use c++ not python or java
Overview
When working with extremely distant celestial objects, astronomers have to work not in hours or days, but years and
centuries. This presents a challenge: Not every year is 365 days, and sometimes we still want to be exact.
Your task is to write a program that converts a number of years to days. Your program must account for leap years.
To make the calculations easier, we will assume we start on January 1,2001. This means:
Every 4th year (that would be 2004,2008,...) has 366 days
Every 100 th year (2100,2200,dots) the leap year is skipped, and has 365 days
Every 400 th year (2400,2800,dots) the leap year skip is skipped, and goes back to having 366 days (just as a
regular leap year would)
This means that every 100 years (from Jan 1,2021), there's not 25, but 24 leap years. Moreover, every 400 years,
there's not 100, neither 96, but 97 leap years.
Write a program in your source directory src named ex1q2.c. This program should take a number of years (as an
integer) and convert it to days following the above rules. Upon non-numerical input, your program must print out
"Error: Invalid input" and exit with a non-zero code.
Example I/O
Enter number of years since Jan 1,2001: 3
1,095 days
Enter number of years since Jan 1,2001: 10
3,652 days
Enter number of years since Jan 1,2001: 150
54,786 days
Part 2 use c + + not python or java Overview When

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!