Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program the will allow the user to enter a four digit integer representi

ID: 3529341 • Letter: W

Question

Write a program the will allow the user to enter a four digit integer representing the year (for example 2013, 1994, 2001, 1950) . The program should execute continually until the user enters the number of 0000 at which point the program will exit. Years must be greater than 1582 or the program will display an error message of invalid input. Once the user enters a valid year output a message Year xxxx is a Leap Year or Year xxxx is not a leap year. The algorithm for determining a leap year is as follows if year is divisible by 400 then is_leap_year else if year is divisible by 100 then not_leap_year else if year is divisible by 4 then is_leap_year else not_leap_year

Explanation / Answer

/***100% WORKING CODE, PLEASE RATE 5 STARS****/

#include<iostream>

using namespace std;

int main(){

int year;

while(1){

cout<<"please enter a 4 digit integer representing year and 0000 to exit : ";

cin>>year;

if(year==0000) return 0;

if(year<=1582){ cout<<"invalid input ";continue;}

if(year@0==0)cout<<"Year "<<year<<" is a leap year ";

else if(year0==0)cout<<"Year "<<year<<" is not a leap year ";

else if(year%4==0)cout<<"Year "<<year<<" is a leap year ";

else cout<<"Year "<<year<<" is not a leap year ";

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote