need help with a program i am writing

Hi there i am just starting out with c++ and learning on my own.
i play a mud that uses its own calender .

http://wiki.midkemiaonline.com/Calendar is the calendar it is using

I am trying to convert a past date into the past game date and wrote this program . However i am having problems with the last while loop and cant see what is wrong. The program is giving crazy day numbers and year numbers .
the values i am entering are .

Please enter current date (month date hour rounded down to the nearest midkemia day : 11 04 21

please enter log date (month date hour rounded down to the nearest midkemia day):
01 12 21

Please enter current midkemia date enter date in game to get this the month must be numeric see http://wiki.midkemiaonline.com/Calendar to get this (day month) and year :
04 02 52


the output should be in the range of the calender for kima in the year 41 dont have a exact date.

the code is and it is not good coding ill admit.

the problem i am having is in the last while loop i havent a clue what is wrong but it gives the output for the input above as .

log date was day :2147483639month :2year :4

Any help would be appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>

using namespace std;

 

int main ()

 

{

    long int hr1, hr2, mon1, mon2, day1, day2,mday1,mmonth2,result1, result2, result3, result4, result5, result6, result7 ,result8,result9,result10,result11,calcmday,calcmonth,curcalday,myr1,myrcur;

    const double DaysInMonth[13] = {0,31,28,31,30,31,30,31,31.30,31,30,31};
	const int DaysInYear[13] = {0,31,59,90,120,151,181,212,243,273,304,334,365};
	const double DaysInMidMonth[12] = {0,1,18,15,10,12,45,1,11,37,11,39};
	const double DaysInmidyear[12] = {0,1,19,34,44,56,101,112,149,160,200};

    

 
	system("CLS");
 

  cout << "Please enter current date (month date hour rounded down to the nearest midkemia day ): ";

  cin >>   mon2 >> day2 >>hr1;

  cout << "please enter log date (month date hour rounded down to the nearest midkemia day): "; 
  cin >>   mon1 >> day1>>hr2;

   cout << "Please enter current midkemia date enter date in game to get this the month must be numeric see http://wiki.midkemiaonline.com/Calendar to get this (day month) and year  : "; 
  cin >> mday1 >> mmonth2 >>myr1 ;

 if (hr1>hr2){
	 result3=hr1-hr2;
 }
 else 
	 result3=hr2-hr1;

  result1 = mon2-mon1;
  result2 = day2-day1;
  result4 = result1[DaysInYear];
  result5 = result4+result2;
  if (result5!=0){
  result6 = ((result5*24)/3)+result3;
  cout<<"debug";
  }
  else
	  result6=result3;
  
   cout << "our days to have passed =" << result5 << "\n " ;
  cout << "midkemia days that have passed =" << result6 << "\n " ;

  cout <<"calculating midkemia date this could take a second \n";
  
  result7= mmonth2[DaysInmidyear] ;
  cout <<"days total this month:"<< result7<<"\n";
  result8= result7-mday1;
  result9= (result8 - result6)+mday1;
  if (result9 <= 0){ 
   result9=result9+200;
   cout << "days since log date:" <<result9 << "\n" ;
  }
  else
	cout << "days since log date:" <<result9 << "\n" ;
  if (result9-mday1==0){
	  result10=mmonth2-1;
		  result11=result10[DaysInMidMonth];
	  cout << "log date was day  "<<result11 <<"month  " <<result10 << "year" << myr1 <<result10;
  } 
  else
	  if(result9-mday1>0)  {
		  result10=mmonth2;
			  result11=result9-mday1;
			  cout << "log date was day  "<<result11 <<"month  " <<result10  << "year" << myr1 ;
	  }
	  else {
	result11=result9-mday1;
	result10=mmonth2;
	
	while (result11<=0){
			
			
				curcalday=result10[DaysInMidMonth];
				result11=result11-curcalday;
				result10=mmonth2-1;
				
				if(result10==0){
				myrcur=myr1-1;
			}
		}
					
			cout << "log date was day  :"<<result11 <<"month  :" <<result10 <<"year  :"<<myrcur;
	  }

  return 0 ;
}




Topic archived. No new replies allowed.