I have looked around on this forum and none of the past posts really addressed my issue. I created a .txt file with cust no first and last name. I open the file and read in the first line of the file, this part works well. And it displays to the screen correctly. I need to read the next line in the file to get the subject code, title, price and quantityto display on the screen. This part is not working. When I do a break point the subjectcode is 84 T. Is the 84 the equivelant to T? The title only brings in 3 char instead of the whole title.
I don't know if its they way I'm declaring the strings or if I'm not reading the next line of data correctly.
This forum has been a wonderful resource for newbie's like me
Following is the code up till the the subject code and title.
Here is the txt file. Thanks for any help
12345 Mike McGee
T C++ Programming 75.00 6
H History of C++ Program lanuage 45.00 5
R The Bible 100.0 10
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
// declare constants
double TECH_DISC = .05;
double SCIENCE_DISC = .04;
double HISTORY_DISC = .03;
double lIT_DIC = .05;
double RELIGION_DISC = .05;
double STATE_TAX = .06;
int main()
{
//Declare and initialize variables
ifstream infile;
int CustomerNumber;
char SubjectCode;
// char Title;
double Price;
int Quantity;
double SubTotalT;
double SubTotalS;
double SubTotalM;
double SubTotalH;
double SubTotalL;
double SubTotalR;
double TotalofInvoice;
double AmtofDisc;
string FirstName;
string LastName;
string Title;
infile.open("mid-term.txt");
if (!infile)
{
cout << "Cannot open the input file." << endl;
cout << "Program terminates!!!" << endl;
return 1;
}
cout << fixed << showpoint << setprecision(2);
infile >> CustomerNumber >> FirstName >> LastName;
cout << "-------------------------------------------------------------------" << endl;
cout << "Customer Number: " << CustomerNumber << setw(30)
<< "Customer Name: " << FirstName << " " << LastName << endl;
cout << "-------------------------------------------------------------------" << endl;
cout << endl;
cout << "Category" << setw(10) << "Title" << setw(25) << "Price" << setw(15) << "Quantity" << setw(15) << "Discount" << endl;
cout << endl;
// infile >> SubjectCode >> Title >> Price >> Quantity;
infile >> SubjectCode >> Title;
cout << SubjectCode << setw(10) << Title << endl; //setw(25) << Price << setw(15) << Quantity << setw(15) << endl;