can u help me with this because when i compile it. it tells me toenter the date
ID: 3617986 • Letter: C
Question
can u help me with this because when i compile it. it tells me toenter the date and when i enter the date it doesn't tell me thenumber of days. the whole thing is gone.#include <cstdlib> #include <iostream>
using namespace std; bool isleapyear(int years); int main() {int day, month, year, daynumber; char ch; cout<<" enter a date(mm-dd-yyyy) : "; cin>>month; cin>>ch; cin>>day; cin>>ch; cin>>year;
daynumber=0; while (month>1) { switch (month-1) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daynumber+=31; break; case 4: case 6: case 9: case 11: daynumber+=30; break; case 2: daynumber+=28; break; if(isleapyear(year)) daynumber++; break; } month--; } daynumber+=day; cout<<" the day number is "<<daynumber;
return 0; } bool isleapyear(int years) { if(((years%4==0)&&(years%100!=0))||((years%100==0)&&(years%400==0))) return true; return false; }
#include <cstdlib> #include <iostream>
using namespace std; bool isleapyear(int years); int main() {int day, month, year, daynumber; char ch; cout<<" enter a date(mm-dd-yyyy) : "; cin>>month; cin>>ch; cin>>day; cin>>ch; cin>>year;
daynumber=0; while (month>1) { switch (month-1) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daynumber+=31; break; case 4: case 6: case 9: case 11: daynumber+=30; break; case 2: daynumber+=28; break; if(isleapyear(year)) daynumber++; break; } month--; } daynumber+=day; cout<<" the day number is "<<daynumber;
return 0; } bool isleapyear(int years) { if(((years%4==0)&&(years%100!=0))||((years%100==0)&&(years%400==0))) return true; return false; }
#include <cstdlib> #include <iostream>
using namespace std; bool isleapyear(int years); int main() {int day, month, year, daynumber; char ch; cout<<" enter a date(mm-dd-yyyy) : "; cin>>month; cin>>ch; cin>>day; cin>>ch; cin>>year;
daynumber=0; while (month>1) { switch (month-1) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daynumber+=31; break; case 4: case 6: case 9: case 11: daynumber+=30; break; case 2: daynumber+=28; break; if(isleapyear(year)) daynumber++; break; } month--; } daynumber+=day; cout<<" the day number is "<<daynumber;
return 0; } bool isleapyear(int years) { if(((years%4==0)&&(years%100!=0))||((years%100==0)&&(years%400==0))) return true; return false; }
Explanation / Answer
cout<<" enter a date(mm-dd-yyyy) : "; cin>>month; cin>>ch; cin>>day; cin>>ch; cin>>year;
cout<<" Enter the month:"; cin>>month; cout<"Enter the day: "; cin>>day; cout<<"Enter the year: "; cin>>year;
There is no data type in C++ which deal like this type of input (5-3-2001)
cout<<" enter a date(mm-dd-yyyy) : "; cin>>month; cin>>ch; cin>>day; cin>>ch; cin>>year;
cout<<" Enter the month:"; cin>>month; cout<"Enter the day: "; cin>>day; cout<<"Enter the year: "; cin>>year;
There is no data type in C++ which deal like this type of input (5-3-2001)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.