Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help finishing this code. please help and zoom in if needed! Write a program that reads an integer which represents a year. The program

need help finishing this code. please help and zoom in if needed!

image text in transcribed

image text in transcribed

Write a program that reads an integer which represents a year. The program should then determine if the year was/is/will be a leap year (a year made up of 366 days.) A leap year is a year that is divisible by 4 with the following exception the centurial years that are divisible by 100 but not divisible by 400, such as 1700, 1800, 1900, and 2100, are NOT leap years. The century years that are divisible by 400, ARE leap years, for instance 1600, 2000, and 2400. Your previous leap year program used nested if-else constructs (and only nested if-else, no && or operators). Using the same divisiblity logic, this program should use one single condition involving logical and and or (& & and I 1) that represents the whole leap year condition Hint Here you will have a single if condition, such as the following: if ( ( (condition 1) && (condition 2)) || (condition 3)) { 17 year is a leap year else Il year is not a leap year } Your program should output one of the following statements based on whether or not XXXX is a leap year XXXX. is a leap year. XX.X.X. is not a leap year. When the input is as shown if Figure 1. your program should produce output as shown in Figure 2. Figure 1: (sample input) 2018 Figure 2 (sample output) 2018 is not a leap year. 5 #include 6 using namespce std; 7 int main() 9 { int year, condition 1, condition 2, condition 3; if ( ( (condition 1) && (condition 2)) || (condition 3)) 13 cout

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

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions