Question: Skeleton code // Submit this original main function with only provided cin and cout statements int main() { int yearX, yearY; // Both inputs are

 Skeleton code // Submit this original main function with only providedcin and cout statements int main() { int yearX, yearY; // Bothinputs are positive integers, but you do not know which is larger

Skeleton code

// Submit this original main function with only provided cin and cout statements int main() { int yearX, yearY; // Both inputs are positive integers, but you do not know which is larger cin >> yearX >> yearY; int numLeapYears; ///////////////////////////////////////////////// // You Code Here, modifying numLeapYears ///////////////////////////////////////////////// cout  

Sample Output

1. Input: 1999 2000/ Output: 1

2. Input: 2000 1999/ Output: 1

3. Input: 2004 1999/ Output: 2

4. Input: 2100 1999/ Output: 25

5. Input: 2099 2100/ Output: 0

Introduction The students shall solve a very simple problem today: Given two years, please count the number of leap years between these two years (both ends inclusive). What is leap year? : Scientists in astronomy find that the earth takes a little more time (roughly more than 5 hours) than 365 days to finish a circle on its orbit surrounding the sun. This error will accumulate every year. Without any intervention, the start date of four seasons on earth will gradually shift, rendering systematic problems. Therefore, a leap year with 366 days is created to mitigate this error. Different from normal years, a leap year has 29 days in February. Clearly, not every year is a leap year. To decide whether a given year is a leap year, there are three rules as follows: 1. A year is a leap year if it is perfectly divisible by 400 2. A year is not leap year if divisible by 100 but not divisible by 400 3. A year is a leap year if divisible by 4 but not divisible by 100 Clearly this is a question requiring you to make different processing based on some conditions, and you are expected to use the conditional structure in C++ to implement this. (if, else if, else) Skeleton and Task Description Skeleton Code and Input/Output: There is only one main function, and you are expected to finish all the required code within this main function. // Submit this original main function with only provided cin and cout statements int main() \{ int yearX, yearY; // Both inputs are positive integers, but you do not know which is larger cin yearX yearY; int numLeapYears; ////////////////////////////////////////// // You Code Here, modifying numLeapYears ///////////////////////////////////////// cout numLeapYears; return 0 3 NOTE 1: Both of yearX and yearY are by default positive integers, all of our grading test cases will be positive. But you do NOT know which one is larger! NOTE 2: Both of yearX and yearY should be included in the counting of leap years. You are now recommended to read the rest of the contents together with the skeleton code. The code structure is simple: - main () function is provided, do NOT add or delete any statement on I/O stream. - You are expected to finish everything within this main function. - You are NOT allowed to include any extra library if not given

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 Databases Questions!