![]() |
| | #1 |
| Registered User Join Date: Oct 2001
Posts: 30
| problems with output from code Enter in the letter s to find out if a specific year is a leap year, Enter in the letter r to find the number of days between 2 years, Enter in the letter q to quit the program: s 1Input a year between 1582 and 4000: 1600 1 is a leap year. //Tell if a certain year is a leap year or the number of days between 2 years. #include <iostream> #include <cmath> int main() { int doYearRange(); int doSpecificYear(); char getChoice; while (getChoice !='s' && getChoice !='r' && getChoice !='q') { std::cout <<"Enter in the letter s to find out if a specific year is a leap year,"<<endl; std::cout<<"Enter in the letter r to find the number of days between 2 years,"<<endl; std::cout<<"Enter in the letter q to quit the program: "; std::cin >>getChoice; } if (getChoice =='s') doSpecificYear(); else std::cout<<"You have chosen to quit the program."<<endl; return 0; } int getYear() { int getYear; while (getYear <= 1582 || getYear >= 4000) { std::cout<<"Input a year between 1582 and 4000: "; std::cin>>getYear; } } bool isLeapYear(int) { bool LeapYear; if (getYear() % 400 == 0) LeapYear=true; else if ( getYear() % 4 != 0 || getYear() % 100 == 0) LeapYear=false; else LeapYear=true; } void doSpecificYear() { bool LeapYear; std::cout<<getYear; if (isLeapYear(LeapYear) == LeapYear == true) std::cout<<getYear<<" is a leap year."<<endl; else std::cout<<getYear<<" is not a leap year."<<endl; } |
| simhap is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| dir output problems | willc0de4food | C Programming | 3 | 04-18-2006 05:47 AM |
| Minute Program output problems | Cobalt | C++ Programming | 12 | 10-12-2003 10:16 AM |
| weird code output | noob2c | C++ Programming | 9 | 08-03-2003 07:34 AM |
| Output problems with structures | Gkitty | C Programming | 1 | 12-16-2002 05:27 AM |
| Problems with output formatting | supaben34 | C++ Programming | 0 | 11-22-2002 11:22 PM |