C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-08-2001, 12:43 PM   #1
Registered User
 
Join Date: Oct 2001
Posts: 30
problems with output from code

Surprise Surprise I am having problems once again. Any help is apreciated. Here is my full code so far. The code compiles but then here is what I get when i do a.out (The s and the 1600 are hte user inputted values, it doesnt matter what number i put in instead of 166 is long as it is between 1582 and 4000 I still get the same output "1 is a leapyear."):

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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 09:53 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22