Compiles but not outputting everything (enums & classes)

I have to write a program that takes in 2 numbers (in millions of years) and outputs the geological time frames encompassed in those two numbers. I have the file compiling and running mostly, it just doesn't output the time frames. I assume I haven't connected the enum or class together correctly, but I'm still new to this so I'm not sure.

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <iostream>
#include <string>

using namespace std;

enum PeriodName 
{
   PRECAMBRIAN, CAMBRIAN, ORDOVICIAN, SILURIAN, DEVONIAN, CARBONIFEROUS,
   PERMIAN, TRIASSIC, JURASSIC, CRETACEOUS, PALEOGENE, NEOGENE
   //Enum type that holds the period names
};

class Period
{
   public : 
   Period()
   {
      curPeriod = PRECAMBRIAN;
   };//Period set to precambrian
   
   Period(PeriodName name)
   {
      curPeriod = name;
   };//period set to periodName
   
   string toString(PeriodName name)
   {
      string periodName;
      switch(name)
      {
         case PRECAMBRIAN:
         periodName = "Precambrian";
         break;
         case CAMBRIAN:
         periodName = "Cambrian";
         break;
         case ORDOVICIAN:
         periodName = "Ordovician";
         break;
         case SILURIAN:
         periodName = "Silurian";
         break;
         case DEVONIAN:
         periodName = "Devonian";
         break;
         case CARBONIFEROUS:
         periodName = "Carboniferous";
         break;
         case PERMIAN:
         periodName = "Permian";
         break;
         case TRIASSIC:
         periodName = "Triassic";
         break;
         case JURASSIC:
         periodName = "Jurassic";
         break;
         case CRETACEOUS:
         periodName = "Cretaceous";
         break;
         case PALEOGENE:
         periodName = "Paleogene";
         break;
         case NEOGENE:
         periodName = "Neogene";
         break;
      }
      return periodName;
   };//Returns date as string
   
   int toInt(PeriodName name)
   {
      int startingYear;
      switch(name)
      {
         case PRECAMBRIAN:
         startingYear = 4500;
         break;
         case CAMBRIAN:
         startingYear = 570;
         break;
         case ORDOVICIAN:
         startingYear = 500;
         break;
         case SILURIAN:
         startingYear = 435;
         break;
         case DEVONIAN:
         startingYear = 395;
         break;
         case CARBONIFEROUS:
         startingYear = 345;
         break;
         case PERMIAN:
         startingYear = 280;
         break;
         case TRIASSIC:
         startingYear = 225;
         break;
         case JURASSIC:
         startingYear = 192;
         break;
         case CRETACEOUS:
         startingYear = 136;
         break;
         case PALEOGENE:
         startingYear = 65;
         break;
         case NEOGENE:
         startingYear = 23;
         break;
      }
      return startingYear;
   };//Returns date as integer
   void increment(PeriodName);//Does nothing if period is already Neogene
   
   private:
   PeriodName curPeriod;
};

int main()
{
   Period period;
   Period per(CAMBRIAN);
   PeriodName name;
   char ch = 'y';
   int range1, range2;
   
   while (ch=='y' || ch=='Y')
   {
      cout << "Enter the range of the prehistoric dates" << endl 
           << "(in million years, seperated by a space): ";
      cin >> range1 >> range2;
      cout << endl << "Period Name\t Starting Date" << endl;
      cout << "-----------\t -------------" << endl;
      
      for (name = PRECAMBRIAN; name <= NEOGENE; name = PeriodName(name+1))
      {
         if(period.toInt(name) <= range1 && period.toInt(name)>=range2)
         
            cout << period.toString(name) << "\t\t" 
                 << period.toInt(name) << endl;
         
      }
      
      cout << endl;
      cout << "Do you want to continue?" << " (Press 'n' to exit): ";
      cin >> ch;
      cout << endl;
   }
   return 0;
}
What exactly is it that you want it to output?


Enter the range of the prehistoric dates
(in million years, seperated by a space): 500 200

Period Name	 Starting Date
-----------	 -------------
Ordovician		500
Silurian		435
Devonian		395
Carboniferous		345
Permian		280
Triassic		225

Do you want to continue? (Press 'n' to exit):  
That is exactly what I want it to output! For me it does not show the periods below period name and starting date. Is that box you're showing the result of you compiling and running the program yourself?
Registered users can post here. Sign in or register to post.