my leap year function doesn\'t quite work: output should be: 1700-> not leap yea
ID: 3609544 • Letter: M
Question
my leap year function doesn't quite work:output should be: 1700-> not leap year
2000-> leap year
1992-> leap year
need help with age function
is there anyway to get rid of yesNo() and just do all that inmain.
if you could post code so i could compare that would be greatthanks.
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
bool leapYear(int year);
void birthDate(int &year, int &day, int &month);
int age(int year, int day, int month);
char yesNo();
int main(int argc, char *argv[]){
int year, month, day;
char userchar;
do{
cout << "Leap year birthday Program" << endl <<endl;
birthDate(year, day, month);
userchar=yesNo();
cout << endl;
}
while (userchar=='Y' ||userchar=='y');
system("PAUSE");
}
bool leapYear(int year)
{
if (!(year%100==0) &&(year%4==0)){
cout << "Lucky you, born in aleapyear!" << endl;
return true;}
else if (year/400){
cout << "Lucky you, born in aleapyear!" << endl;
return true;}
else if (year/4 && year/100){
cout << "Sorry, you were not born ina leapyear" << endl;
return true;}
}//end leapYear function
void birthDate(int &year, int &day, int &month)
{
cout << "Please enter the year of your birth: ";
cin >> year;
cout << "Please enter the month of your birth: ";
cin >> month;
cout << "Please enter the day of your birth: ";
cin >> day;
cout << endl;
leapYear(year);
age(year, day, month);
}//end birthDate function
int age(int year, int day, int month){
int result;
return result;
}//end age function
char yesNo(){
char result;
bool valid=false;
while (valid==false){
cout<<"Do you want tocontinue? (Y/y or N/n) ";
cin>>result;
//check to see if it isvalid..
if ((result=='y') ||(result=='Y') || (result=='n') || (result=='N'))
valid=true;
else
cout<<"You have to type a valid character.... Tryagain"<<endl;
}//end while
//sends the valid character back
return result;
}
Explanation / Answer
please rate - thanks this may get you started. without more details, I can't help #include using namespace std; int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int doy ( int, int); int main () { int TotalDays,cmonth,cday,cyear,bmonth,bday,byear,day; int months,years,i; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.