JustPaste.it

#include //Basic Input and Output
#include //allows file input and output
#include //allows the std::exit(0) command
#include // allows strings
#include //allows setw
using namespace std;

int main ()
{
    //Variables
    ifstream datain("data.txt");//The input file
    string first,last,residencefull,pet;
    char residence = ' ';
    int hours;    
    
    //Column Listing
    cout << endl << "Last Name" << std::setw(20) << "First Name" << std::setw(20) << "Residence" << std::setw(20) << "Hours Home" <<std::setw(20) <<  "Recommendation"<< endl << endl;
    
    if(!datain) //Check if the file is present
    {
        cout<< "The file does not exist";
        std::exit(0);
    }    
    
    for(;!datain.eof();) //outputs till end of file
    {
        datain >> first >> last >> residence >> hours;
        
        //determining the pet
        if(residence = 'A')
        {        
        if(residence = 'H')
        {        
        if(residence = 'D')
        {//end determining the pet
    
        //The Output
        cout << std::setw(20)<< std::left << last << std::setw(20) << std::left << first << std::setw(20) << residencefull << std::setw(20) << hours << std::setw(20) << pet << endl;    
    }
    
    cout << endl;
    
}//End main