after i input the three letter, i cant get the number back..

#include <iostream>
using namespace std;

class Month{


public:
int month;
Month(char& one, char& two, char& three);
Month(int& numb);
Month();
void input1(istream& input);
void input2(istream& input);
void output1(ostream& output);
void output2(ostream& output);
};

int main (){
char x,y,z;
int num,number;
char let1,let2,let3;	

cout<<"Enter the month as a number(1-12): ";
Month k;
k.input1(cin);
cout<<"That month is: ";
k.output1(cout);
cout<<endl;
cout<<"Enter the month as three letters: ";
cin.get(x);
cin.get(y);
cin.get(z);
Month cur(x,y,z);
cur.input1(cin);
cur.output2(cout);


cout<<endl;
system("pause");
}

Month::Month(char& one, char& two, char& three){
if(((one=='J')||(one=='j'))&&((two=='A')||(two=='a'))&&((three=='N')||(three=='n'))){
month=1;
}
if(((one=='F')|| (one=='e'))&&((two=='E')||(two=='e'))&&((three=='B')||(three=='e'))){
month=2;
}
if(((one=='M')||(one=='m'))&&((two=='A')||(two=='a'))&&((three=='R')||(three=='r'))){
month=3;
}		
if(((one=='A')||(one=='a'))&&((two=='P')||(two=='p'))&&((three=='R')||(three=='r'))){
month=4;
}				
if(((one=='M')||(one=='m'))&&((two=='A')||(two=='a'))&&((three=='Y')||(three=='y'))){
month=5;
}		
if(((one=='J')||(one=='j'))&&((two=='U')||(two=='u'))&&((three=='N')||(three=='n'))){
month=6;
}	
if(((one=='J')||(one=='j'))&&((two=='U')||(two=='u'))&&((three=='L')||(three=='l'))){
month=7;
}		
if(((one=='A')||(one=='a'))&&((two=='U')||(two=='u'))&&((three=='G')||(three=='g'))){
month=8;
}		
if(((one=='S')||(one=='s'))&&((two=='E')||(two=='e'))&&((three=='P')||(three=='p'))){
month=9;
}		
if(((one=='O')||(one=='o')) &&((two=='C')||(two=='c'))&&((three=='T')||(three=='t'))){
month=10;
}		
if(((one=='N')||(one=='n'))&&((two=='O')||(two=='o'))&&((three=='V')||(three=='v'))){
month=11;
}				
if (((one=='D')||(one=='d'))&&((two=='E')||(two=='e'))&&((three=='C')||(three=='c'))){
month=12;
}

}

Month::Month(int& numb){
month=numb;

}

Month::Month():month(1){
//empty
}

void Month::input1(istream& input){
input>>month;
}

void Month::input2(istream& input){
input>>month;    
}







void Month::output1(ostream& output){

switch(month){
case 1:
output<<"Jan";
break;
case 2:
output<<"Feb";
break;
case 3:
output<<"Mar";
break;
case 4:
output<<"Apr";
break;
case 5:
output<<"May";
break;
case 6:
output<<"Jun";
break;
case 7:
output<<"Jul";
break;
case 8:
output<<"Aug";
break;
case 9:
output<<"Sep";
break;
case 10:
output<<"Oct";
break;
case 11:
output<<"Nov";
break;
case 12:
output<<"Dec";
break;
default:
output<<"You didnt enter correctly";
}
}
void Month::output2(ostream& output){

switch(month){
case 1:
output<<"1";
break;
case 2:
output<<"2";
break;
case 3:
output<<"3";
break;
case 4:
output<<"4";
break;
case 5:
output<<"5";
break;
case 6:
output<<"6";
break;
case 7:
output<<"7";
break;
case 8:
output<<"8";
break;
case 9:
output<<"9";
break;
case 10:
output<<"10";
break;
case 11:
output<<"11";
break;
case 12:
output<<"12";
break;
default:
output<<"You didnt enter correctly";
}  
     
     
     
}
]

Edited 6 Years Ago by WaltP: Fixed CODE Tags. Please use the PREVIEW button!

I would just use strings instead of 3 chars xD. But anyways, If you were told to do it that way for school or whatever, whatevers :P. Ok your problem: Don't use cin.get().

try replacing:

cin.get(x);
cin.get(y);
cin.get(z);

with

std::cin >> x;
std::cin >> y;
std::cin >> z;

and get rid of

cur.input1(cin);
This article has been dead for over six months. Start a new discussion instead.