shares.txt(Save the file in the D drive.Then the path of the file pointing to that file is D:\\\\shares.txt ) williams kane 500 15 18 ________________________________________________ C++ code #include #include using namespace std; int main() { //Declaring variables int noOfShares; double purPrice,sellPrice; string firstname,lastname,fname,lname; double no_of_shares_sold,purchase_price,selling_price,tot_amt_invested,amount_received_after_sell,se rvice_tax_during_buy,service_tax_during_sell,total_tax,amount_profit_lost; //fileInput reference ifstream dataIn; //Opening input file dataIn.open(\"D:\\\\shares.txt\"); //Reading the data from the file while(dataIn>>fname>>lname>>noOfShares>>purPrice>>sellPrice) { firstname=fname; lastname=lname; no_of_shares_sold=noOfShares; purchase_price=purPrice; selling_price=sellPrice; } //closing the input stream dataIn.close(); //calculating total amount invested tot_amt_invested=no_of_shares_sold*purchase_price; //Calculating service tax during buying of shares service_tax_during_buy=tot_amt_invested*0.015; //calculating the amount received after selling amount_received_after_sell=no_of_shares_sold*selling_price; //Calculating service tax after selling of shares service_tax_during_sell=amount_received_after_sell*0.015; //calculating Total Service tax paid total_tax=service_tax_during_buy+service_tax_during_sell; //calculating amount profit or lost amount_profit_lost=(amount_received_after_sell-tot_amt_invested)-(total_tax); //fileoutput reference ofstream myfile; //Opening the file myfile.open (\"D:\\\\SharesOutput.txt\"); //Writing the contents to the file myfile <<\"No_Of_Shares_sold\"<<\"||\"<<\"Purchase_Price\"<<\"||\"<<\"Sell_Price\"<<\"||\"<<\"Amt_i nvest\"; myfile<<\"||\"<<\"service_charges\"<<\"||\"<<\"Amt_Gained\"<<\"||\"<<\"Amt_received_After_s ell\ \"; myfile<<\"\\t\"< Solution shares.txt(Save the file in the D drive.Then the path of the file pointing to that file is D:\\\\shares.txt ) williams kane 500 15 18 ________________________________________________ C++ code #include #include using namespace std; int main() { //Declaring variables int noOfShares; double purPrice,sellPrice; string firstname,lastname,fname,lname; double no_of_shares_sold,purchase_price,selling_price,tot_amt_invested,amount_received_after_sell,se rvice_tax_during_buy,service_tax_during_sell,total_tax,amount_profit_lost; //fileInput reference ifstream dataIn; //Opening input file dataIn.open(\"D:\\\\shares.txt\"); //Reading the data from the file while(dataIn>>fname>>lname>>noOfShares>>purPrice>>sellPrice) { firstname=fname; lastname=lname; no_of_shares_sold=noOfShares; purchase_price=purPrice; selling_price=sellPrice; } //closing the input stream dataIn.close(); //calculating total amount invested tot_amt_invested=no_of_shares_sold*purchase_price; //Calculating service tax during buying of shares service_tax_during_buy=tot_amt_invested*0.015; //calculating the amount received after selling amount_received_after_sell=no_of_shar.