Loop of hell

I'm trying to make a program for class that should repete till the user enters Q to quit, thproblem is every time I do it makes the program repet the last output with out end. I really need help I can't figure out what i'm doing worng.



The program

#include <iostream>
#include <string>


using namespace std;
int main()
{

enum eras {Neogene, Paleogene, Cretaceous, Jurassic, Triassic, Permian, Carboniferous, Devonian, Silurian, Ordovician, Cambrian, Precambrian};
int yearIn;
int yearOut;
string Q;
cout << "Dates Begin at 23 " << endl;
cout << "numbers repersint milloins" << endl;
cout << "Example 23 = 23,000,000" << endl;
cout << "this is to cut back on typing, Please enjoy the program" << endl;
do
{

cout << "Please enter a date" <<endl;
cin >> yearIn;
if (yearIn != 'Q')
cout <<endl;

if (yearIn >= 4500)
yearOut = Precambrian;
else if (yearIn >= 570)
yearOut = Cambrian;
else if (yearIn >= 500)
yearOut = Ordovician;
else if (yearIn >= 435)
yearOut = Silurian;
else if (yearIn >= 395)
yearOut = Devonian;
else if (yearIn >= 345)
yearOut = Carboniferous;
else if (yearIn >= 280)
yearOut = Permian;
else if (yearIn >= 225)
yearOut = Triassic;
else if (yearIn >= 192)
yearOut = Jurassic;
else if (yearIn >= 136)
yearOut = Cretaceous;
else if (yearIn >= 65)
yearOut = Paleogene;
else if (yearIn >= 23)
yearOut = Neogene;
else if (yearIn <= 22)
{
cout << "Error: Worng Input" << endl;
cout << "Please only use dates starting at 23 million years" <<endl;
}
else if (yearIn =='Q')
yearOut = 'Q';

switch (yearOut)
{
case Neogene : cout << "Neogene Era" <<endl;
break;
case Paleogene : cout << "Paleogene Era" <<endl;
break;
case Cretaceous : cout << "Cretaceous Era" <<endl;
break;
case Jurassic : cout << "Jurassic Era" <<endl;
break;
case Triassic : cout << "Triassic Era" <<endl;
break;
case Permian : cout << "Permian Era" <<endl;
break;
case Carboniferous : cout << "Carboniferous Era" <<endl;
break;
case Devonian : cout << " Devonian Era" <<endl;
break;
case Silurian : cout << "Silurian Era" <<endl;
break;
case Ordovician : cout << "Ordovician Era" <<endl;
break;
case Cambrian : cout << "Cambrian Era" <<endl;
break;
case Precambrian : cout << "Precambrian Era" <<endl;
break;
case 'Q' : cout << "It's over!";
}



}
while (yearOut != 'Q');


return 0;
}
[code] "Please use code tags" [/code]
int yearIn; That variable will hold integers. Don't try to read a character in there.
Topic archived. No new replies allowed.