[code]
void getfilename (string,string&);
void reformat (string);
void writeinfo (ofstream&,string,string);
int main()
{
cout<<fixed<<showpoint<<setprecision(2);
ifstream input;//variable infile represents the name of the file being opened
ofstream output;//
string out_putname="velazq32_taxes";
string filename,lname,status;
getfilename("input",filename);
input.open(filename.c_str());
output.open(out_putname.c_str());
input >> lname;
while (!input.eof())
{
input >> status;
writeinfo(output,lname,status);
reformat(lname);
input >> lname;
}
input.close();
output.close();
return 0;
}
void writeinfo (ofstream& out,string lname,string status)
{
out << left <<"Tax summary for "<<lname<<" family"<<endl;
out<< left<<"Filling status: "<<status<<endl;
}
void getfilename(string filetype,string& filename)
{
cout << "Enter name of " << filetype << " file\n";
cin >> filename;
}
void reformat (string lname)
//Given a word, convert the first letter to upper case and the
//rest of the letters to lower case. The converted word will
//be passed back.
{
int wlen;
wlen = lname.length();
lname[0] = toupper(lname[0]);
for (int i=1; i<wlen; i++)
lname[i] = tolower(lname[i]);
}
Code:
void getfilename (string,string&);
void reformat (string);
void writeinfo (ofstream&,string,string);
int main()
{
cout<<fixed<<showpoint<<setprecision(2);
ifstream input;//variable infile represents the name of the file being opened
ofstream output;//
string out_putname="velazq32_taxes";
string filename,lname,status;
getfilename("input",filename);
input.open(filename.c_str());
output.open(out_putname.c_str());
input >> lname;
while (!input.eof())
{
input >> status;
writeinfo(output,lname,status);
reformat(lname);
input >> lname;
}
input.close();
output.close();
return 0;
}
void writeinfo (ofstream& out,string lname,string status)
{
out << left <<"Tax summary for "<<lname<<" family"<<endl;
out<< left<<"Filling status: "<<status<<endl;
}
void getfilename(string filetype,string& filename)
{
cout << "Enter name of " << filetype << " file\n";
cin >> filename;
}
void reformat (string lname)
//Given a word, convert the first letter to upper case and the
//rest of the letters to lower case. The converted word will
//be passed back.
{
int wlen;
wlen = lname.length();
lname[0] = toupper(lname[0]);
for (int i=1; i<wlen; i++)
lname[i] = tolower(lname[i]);
}
is not capalizing the first words
Tax summary for jones family
Filling status: married
this is my output
i want jones named capatalize for exanple if the input is JoneS to come out has Jones
thanks