Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. id=rand()%9000+1000;
  2.         pet.setId(id);
  3.        
  4.         cout<<"Enter the type of pet"<<endl;
  5.         cin>>type;
  6.         pet.setType(type);
  7.        
  8.         cout<<"Enter the color of the pet"<<endl;
  9.         cin>>color;
  10.         pet.setColor(color);
  11.  
  12.         cout<<"Enter the 'f' if the pet is a female, or 'm' if the pet is a male"<<endl;
  13.         cin>>gender;
  14.         pet.setGender(gender);
  15.  
  16.         cout<<"Enter the date this pet was acquired"<<endl;
  17.         cin>>day;
  18.         dac.setDay(day);
  19.         cin>>month;
  20.         dac.setMonth(month);
  21.         cin>>year;
  22.         dac.setYear(year);
  23.        
  24.         cout<<"Enter the cost of the pet"<<endl;
  25.         cin>>cost;
  26.         pet.setCost(cost);
  27.  
  28.         cout<<endl<<"Your Pet's ID number is: "<<id<<endl<<endl;
  29.        
  30.         ofstream PetFile;
  31.        
  32.         PetFile.open("PetFile.txt", ios_base::out);
  33.        
  34.         if (PetFile.is_open())
  35.         {
  36.             PetFile << "ID: " <<id<<"\n"<< "Type: "<<type<<"\n"<<"Color:" <<color<<"\n"<< "Gender: "<<gender<< "\n" <<"Date Acquired: "<<day<<"/"<<month<<"/"<<year<<endl;
  37.                 PetFile.close();
  38.         }
  39.        
  40.         else
  41.         {
  42.                 cout<<endl<<"Operation unsuccessful"<<endl;
  43.         }
  44.        
  45.         cout<<"Record Added!"<<endl;
  46.  
  47.                 displayMenu();