I need to return the ticket as a string from a function. There are some double variables and when I convert it to to_string it displays 6 zeros after the decimal. How can I format it so it only displays 2 zeros after the decimal when I return the value as a string?
Here is my code:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
static const int NUM_ROWS = 15;
static const int NUM_SEATS = 30;
char SeatStructures[NUM_ROWS][NUM_SEATS];
double cost;
double price[NUM_ROWS];
int rowRequested,
seatNumber;
string PrintTicket(int row, int seat, double cost);
int main()
{
   ifstream SeatPrices;
   SeatPrices.open("SeatPrices.dat");
   if (!SeatPrices)
       cout << "Error opening SeatPrices data file.\n";
   else
   {
       for (int rows = 0; rows < NUM_ROWS; rows++)
   {
       SeatPrices >> price[rows];
       cout << fixed << showpoint << setprecision(2);
   }
   cout << endl << endl;
   }
   SeatPrices.close();
   cout << "In which row would you like to find seats(1 - 15)? ";
   cin >> rowRequested;
   cout << "What is your desired seat number in the row (1 - 30)? ";
   cin >> seatNumber;
   cout << PrintTicket(rowRequested, seatNumber, cost);
   return 0;
}
string PrintTicket(int row, int seat, double cost)
{
    return
   string("\n****************************************\nTheater Ticket\nRow: ") +
   to_string(row) +
   string("\tSeat: ") +
   to_string(seat) +
   string("\nPrice: $") +
   to_string(price[rowRequested - 1]) +
   string("\n****************************************\n\n");
}
/*Data from text file:
12.50
12.50
12.50
12.50
10.00
10.00
10.00
10.00
8.00
8.00
8.00
8.00
5.00
5.00
5.00*/