Chce zeby 4 inputy ktore aktualnie wpisywane sa przez uzytownika zostaly wczytane z pliku ktorego nazwe poda uzytkownik oraz zeby caly output znalazl sie w pliku ktorego nazwe takze poda uzytkownik. Dzieki za pomoc.
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;
string formatDollar(double money);
int main()
{
double price_ticket;
double base_cost;
double total_cost;
double tax_rate;
double tax;
string visiting_team;
// get four required data items from user
cout << "Enter the name of the visiting team: ";
getline(cin, visiting_team, '\n');
cout << "Enter the number of tickets: ";
cin >> num_tickets;
cout << "Enter the price per ticket: ";
cin >> price_ticket;
cout << "Enter the sales tax rate (e.g., 7.0): ";
// convert sales tax rate to decimal form
tax_rate /= 100.0;
// calculate base cost of purchase
base_cost = num_tickets * price_ticket;
// calculate tax due
tax = base_cost * tax_rate;
// factor in tax to get total cost
total_cost = base_cost + tax;
// Generate receipt for the ticket purchase. Neatly
// align the numerical values in column 28.
cout << endl;
cout << " Nets vs. " << visiting_team << " at \"The Rock\"" << endl;
cout << "-----------------------------------------" << endl;
cout << "Number of tickets:" << setw(10) << num_tickets << endl;
cout << "Price per ticket:" << setw(11) <<
formatDollar(price_ticket) << endl;
cout << "Total ticket price:" << setw(9) <<
formatDollar(base_cost) << endl;
cout << "Sales tax:" << setw(18) << formatDollar(tax) << endl;
cout << "-----------------------------------------" << endl;
cout << "Total amount due:" << setw(11) <<
formatDollar(total_cost) << endl;
return 0;
} // end main
/////////////////////////////////////////////////////////
{
// Convert the given dollar amount into
// a string with a leading "$"
ostringstream convert;
convert << setiosflags(ios::fixed);
convert << setprecision(2);
convert << "$" << money;
return convert.str();
} // end formatDollar