Infile Multiple Parts on a Line

Infiles have been a struggle, so multiple pieces of information on one line is proving difficult. For this I need to read in a customer's code, quantity, and price per. For example, the first customer is 46345 6 450.00 all on one line. At the moment only the student name is being printed. This is not a finished product (so I apologize if math or formatting is off), but I cannot continue until the info is being read in properly

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
 #include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int main() 
{
	ifstream infile;
	infile.open("info.txt");
	ofstream outfile;
	outfile.open("out.txt");
	
//All the declarations for codes, discounts, rates, etc
	int CusCode;
	double Quan;
	double PricePer;
	double TotSales;
	double Disc;
	double Comm;
	double Commr;
	double NetPrice;

	int count;
	count = 1;

	outfile << "Student Name: bleh\n";

	while (count <= 10);
	{
//read in the three pieces
		infile >> CusCode >> Quan >> PricePer;
		
		TotSales = PricePer + Quan;
//Begin process of elimination to find comm and disc rate
		if (TotSales > 10000)
		{
			Commr = 4;
			Comm = TotSales * .04;
			Disc = TotSales * .015;
			NetPrice = TotSales - Disc;
		}

		else if (TotSales > 7500)
		{
			Commr = 3;
			Comm = TotSales * .03;
			Disc = TotSales * .015;
			NetPrice = TotSales - Disc;
		}

		else if (TotSales > 5000)
		{
			Commr = 3;
			Comm = TotSales * .03;
			Disc = TotSales * .01;
			NetPrice = TotSales - Disc;
		}
		
		else if (TotSales > 1500)
		{
			Commr = 2;
			Comm = TotSales * .02;
			Disc = TotSales * .01;
			NetPrice = TotSales - Disc;
		}

		else
		{
			Commr = 2;
			Comm = TotSales * .02;
			Disc = TotSales * 0;
			NetPrice = TotSales - Disc;
		}
//outfiles with temporary formatting
		outfile << "-------------------------------\n";
		outfile << "Customer Code Number " << CusCode << "\n";
		outfile << "     $" << setw(5) << TotSales << "  Sales Amount\n";
		outfile << "     $" << setw(5) << Disc << "   Discount\n";
		outfile << "     $" << setw(5) << NetPrice << "   Net Amount\n";
		outfile << "     $" << setw(5) << Comm << "   Commission\n";
		outfile << "     %" << setw(5) << Commr << "   Commission Rate\n";
		outfile << "-------------------------------\n";


		count = count + 1;
	}
	
	return 0;
}
> while (count <= 10);
Yeah, get rid of that ; at the end of this line.

You've written this.
1
2
3
4
while (count <= 10)
{
    // do nothing at all, forever, with no hope of escape
}
I'm blind. Thanks so much!
Topic archived. No new replies allowed.