Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a program that determines if a number is a leap year. By definition, a Leap Year is: Evenly divisible by 4. Evenly divisible

C++ image text in transcribed
Write a program that determines if a number is a leap year. By definition, a Leap Year is: Evenly divisible by 4. Evenly divisible by 100 if and only if evenly divisible by 400. X/Y is evenly divisible if X/Y has a remainder of 0. The program should do the following: Create three Boolean variables, isDivBy4, isDivBy100, isDivBy400. Request a year as input. Determine if the year satisfies each leap year condition. Store the state of each condition as Boolean values (true or false) in the variables from a). Use the stored values to output and answer the following questions. Is the year evenly divisible by 4? Yes. Is the year evenly divisible by 100? No. Is the year evenly divisible by 400? Yes. This output will help you to diagnose Issues with your logic if the final output is incorrect. Output if the year is or is not a leap year. Test your program with the following input values: 2104, 2364, 2400 (leap years) 1800, 2100, 2200 (not leap years) Example Output 1 (not a leap year, Input is in bolded italics): Enter a year: 1800 Is the year evenly divisible by 4? Yes. Is the year evenly divisible by 100? Yes. Is the year evenly divisible by 400? No. 1800 is not a leap year. Example Output 2 (is a leap year, input is in bolded italics): Enter a year: 2364 Is the year evenly divisible by 4? Yes. Is the year evenly divisible by 100? No. Is the year evenly divisible by 400? No. 2104 is a leap year

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago