"$" removal after first record

I have a text file that I'm reading from and then displaying the following info. I don't want the dollar sign to be printed after the first record is read. Any advice?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Haroldson                $   180.60         $    7.79   MO
Holder                   $   733.50         $   31.66   MO
Bascomb                  $   395.55         $   26.90   KS
Maartens                 $   431.46         $   18.62   MO
Stivers                  $   418.00         $   18.04   MO
Tomlin                   $   167.40         $   11.38   KS
DuPuy                    $    75.90         $    5.16   KS
Pendleton                $   531.00         $   22.92   MO
Trenton                  $   369.99         $   25.16   KS
Bourne                   $  1621.75         $  110.28   KS
Madison                  $  3746.25         $  161.69   MO
Benton                   $   189.98         $    8.20   MO
Graham                   $   226.40         $    9.77   MO
Penniman                 $   111.75         $    7.60   KS
Wurtz                    $   670.00         $   28.92   MO
Granville                $   475.00         $   32.30   KS
Holder                   $   838.60         $   57.02   KS
Saville                  $   410.88         $   17.73   MO
Duncan                   $   370.90         $   16.01   MO
Brent                    $   810.00         $   34.96   MO
I'm not sure what you mean, exactly; could you give an example of the output that you want? What have you tried so far?
1
2
3
4
5
6
7
8
9
10
11
std::string person_name;
char dollar_dummy;
int first_money;
char dollar_dummy2;
int second_money;
std::string currency;

while(inFile >> person_name >> dollar_dummy >> first_money >> dollar_dummy2 >> second_money >> currency)
{
    // Your code. . .
}
TwilightSpectre, I'm wanting to only print out the first line with the "$", then not after that. The following is the entire code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using namespace std;

const double MO_SALES_TAX_RATE = 0.04316;
const double KS_SALES_TAX_RATE = 0.068;

double saleAmountCalc   (int quantity, double price);
double salesTaxCalc     (double totalSalesAmt, string stateCode);
void   displaySalesData (string custName, double totalSalesAmt, double salesTaxAmt, string stateCode);

int main()
{
	string custName;
	string stateCode;
	int    quantity         = 0;
	double price            = 0.00;
	double totalSalesAmt    = 0.00;
	double salesTaxAmt      = 0.00;
	double salesTotal       = 0.00;
	double taxTotal         = 0.00;
	double moTax            = 0.00;
	double ksTax            = 0.00;
	char dollarSign = '$';

	ifstream inputFile;
	inputFile.open("SalesRegister.txt");

	if (!inputFile)
	{
		cout << endl << "Input file not found." << endl << endl;
		system("pause");
		return  -1;
	}

	cout << fixed << setprecision(2);
	cout << "Customer Name:           Total Sales        Total Tax" << endl;
	cout << "------------------------------------------------------------" << endl;
	inputFile >> custName >> stateCode >> quantity >> price;

	while (!inputFile.eof())
	{
		totalSalesAmt = saleAmountCalc(quantity, price);
		salesTaxAmt = salesTaxCalc(totalSalesAmt, stateCode);
		displaySalesData(custName, totalSalesAmt, salesTaxAmt, stateCode);
		salesTotal += totalSalesAmt;
		taxTotal += salesTaxAmt;

		if (stateCode == "KS")
			ksTax += salesTaxAmt;
		else
			moTax += salesTaxAmt;

		inputFile >> custName >> stateCode >> quantity >> price;
	}

	cout << endl;
	cout << setw(26) << dollarSign << setw(9) << salesTotal
		 << setw(10) << dollarSign << setw(8) << taxTotal 
		 << "   " << "Total" << endl << endl;

	cout << setw(35) << "Sales Tax:" << setw(18) << moTax 
		 << "   MO" << endl << endl;
	cout << setw(53) << ksTax << "   KS" << endl << endl;

	inputFile.close();
	system("pause");
	return 0;
}

double saleAmountCalc (int quantity, double price)
{
	double saleAmount;
	saleAmount = quantity * price;

	return saleAmount;

}

double salesTaxCalc (double totalSalesAmt, string stateCode)
{
	
	double salesTaxAmt;
	
	if (stateCode == "KS")
		salesTaxAmt = totalSalesAmt * KS_SALES_TAX_RATE;
	else
		salesTaxAmt = totalSalesAmt * MO_SALES_TAX_RATE;

	return salesTaxAmt;
}

void displaySalesData (string custName, double totalSalesAmt, double salesTaxAmt, string stateCode)
{
	char dollarSign = '$';
	cout << fixed << setprecision(2);
	cout << left << setw(25) << custName << right << setw(1) << dollarSign
		<< setw(9) << totalSalesAmt << setw(10) << dollarSign << setw(8)
		<< salesTaxAmt << "   " << stateCode << endl;
}
Topic archived. No new replies allowed.