#include<iomanip>
Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): Consider the following incomplete C++ program:…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;
int main(){
ifstream inFile;
ofstream outFile;
string line;
int count1 = 0;
inFile.open(“C:\inData.txt”);
outFile.open(“F:\outData.txt”);
if (inFile.is_open())
{
//if file is open then read from file
while ( getline (inFile,line) )
{
string parsed;
stringstream input_stringstream(line);
int counter =0;
if(count1==0){
while(getline(input_stringstream,parsed,’ ‘))
{
if(counter==0){
outFile << “Name : “<<parsed;
}else if(counter == 1){
outFile << ” “<<parsed;
}else{
outFile << “, Department : “<<parsed<<“n”;
}
counter++;
}
}else if(count1==1){
float gross,tax,bonus,paycheck;
while(getline(input_stringstream,parsed,’ ‘))
{
if(counter==0){
gross=atof( parsed.c_str() );
outFile << setprecision(2) << fixed<<“Monthly Gross Salary: $”<<gross;
}else if(counter == 1){
bonus=atof( parsed.c_str() );
outFile << “, Monthly Bonus: “<<bonus<<“%”;
}else{
tax=atof( parsed.c_str() );
outFile << “, Taxes: “<<tax<<“%n”;
}
counter++;
}
paycheck=(gross+gross*(bonus/100))-(gross+gross*(bonus/100))*(tax/100);
outFile <<“Paycheck: $”<<paycheck<<“n”;
}else if(count1 == 2){
float d,h,as;
while(getline(input_stringstream,parsed,’ ‘))
{
if(counter==0){
d=atof( parsed.c_str() );
outFile << “Distance Traveled: “<<d<<” miles, Traveling Time: “;
}else if(counter == 1){
h=atof( parsed.c_str() );
outFile <<h<<” hoursn”;
}
counter++;
}
as=d/h;
outFile<<“Average Speed: “<<as<<” miles per hourn”;
}else{
float c,t;
int n;
while(getline(input_stringstream,parsed,’ ‘))
{
if(counter==0){
n=atoi( parsed.c_str() );
outFile << “Number of Coffee Cups Sold: “<<n<<“, Cost: $”;
}else if(counter == 1){
c=atof( parsed.c_str() );
outFile <<c<<” per cupn”;
}
counter++;
}
t=n*c;
outFile<<“Sales Amount = $”<<t<<“n”;
}
count1++;
}
}
inFile.close();
outFile.close();
}