When i input a number from 1-12 no matter what the number is i always get "31 days" as an output any suggestions on what to do?
/*
Description: this program will ask the user to input the number of a month then
tell the user how many days are in that month
Algorithm
1. Months 1,3,5,7,8,10,12 have 31 days
2. Month 2 has 28 or 29 days
3. Months 4,6,9,11 have 30
4. Any number above 12 is not valid
*/
#include <iostream>
using namespace std;
int main()
{
int y;
cout << "Input The Number of The Month: ";
cin >> y;
if ( cin.fail())
{ cout << "Input Error Please Enter A number!"<<"\n";
return 1;
}
if ( y >= 13)
{ cout << "Please Enter a valid Number of a month "<<"\n";
return 2;
}
if ( y == 1 || 3 || 5 || 7 || 8 || 10 || 12 )
cout << y << " Has 31 days" << endl ;
else if (y == 2 )
cout << y << "Has 28 days in a regular year 29 days in a leap year" << endl ;
else if( y == 4 || 6 || 9 || 11 )
cout << y << "Has 30 days" << endl ;
return 0;
}