Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For problem 3, I am supplying the code for the confusing logic: // if C || A && B! if (isDivBy400 || (isDivBy4 && !isDivBy100))

For problem 3, I am supplying the code for the confusing logic:

// if C || A && B!

if (isDivBy400 || (isDivBy4 && !isDivBy100))

cout << endl << year << " is a leap year.";

else

cout << endl << year << " is not a leap year

Using C++ (cin,cout) Write A Program That Determines If A Number Is A Leap Year. By Definition, ...

Question: Using C++ (cin,cout) Write a program that determines if a number is a leap year. By definition, a...

Using C++ (cin,cout)

Write a program that determines if a number is a leap year. By definition, a Leap Year is: i) Evenly divisible by 4. ii) 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:

a) Create three Boolean variables, isDivBy4, isDivBy100, isDivBy400. b) Request a year as input. c) 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. For example, if the year is 1600, then isDivBy4 is true, isDivBy100 is true, isDivBy400 is true. d) 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. e) 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. 2364 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

Step: 3

blur-text-image

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

Logics For Databases And Information Systems

Authors: Jan Chomicki ,Gunter Saake

1st Edition

1461375827, 978-1461375821

More Books

Students also viewed these Databases questions