Write a Boolean function that returns TRUE/FALSE if the unsigned int argument passed to it is a Leap Year or Non-Leap Year. The function must throw an “Out Of Range” exception if its argument does not lie between 0 and 2100.
#include#includeenum boolean{false, true} bool;class Cyear{private:int dd, mm, yy;public:void getDate();int isLeap();void putDate();};void Cyear :: getDate(){cout<<"\n Enter Date (dd mm yyyy): ";cin>>dd>>mm>>yy;try{if( (yy < 0) || (yy > 2100) )throw "Out of Range";}catch(char *errmsg){cout<<"\n ERROR: "<}}int Cyear :: isLeap (){return ( (yy % 400 == 0) || ((yy % 4 == 0) && (yy % 100 !=0)) );}void Cyear :: putDate(){if(isLeap())cout<<"\n Is a leap year.";elsecout<<"\n Is not leap year.";}void main(){clrscr();Cyear Odt;Odt.getDate();Odt.putDate();getch();}
Comments
Post a Comment
share your thoughts ....