Making a Table while reading in data

Hello,

For an assignment i need to make a neat table to organize my data. The data needs to be read in using cin, or infile. I've written the code, formulas and prompts. But I am having trouble in figuring out what to write to make this table work.

This is way the way I would like my table to look (minus all the dots):


Employee number.....Hours Worked.....Rate of Pay.....Total Earned
____..........................____..................____................_____
____..........................____..................____................_____
____..........................____..................____................_____


The blanks represent where i would like to read in the information for the first three columns then the total earned would be calculated using the formula: total=hours*pay. It is also okay if the table comes at the very end after having read in all the data, so long as it is aligned.

here's the code that does not do exactly what i want:

1
2
3
4
5
    cout << "Customer #" << "\tAmount Ordered" << "\t\tAmount Paid" 
         << "\tBalance" << endl << endl;
    
    cout << customer << "\t\t$" << ordered << "\t\t\t$" << paid << "\t\t\t$" 
         << balance << endl;


I've tried this code in the while loop as well as out.
You probably want to learn a bit about the setw() and setfill() functions from the <iomanip> library:

http://www.cprogramming.com/tutorial/iomanip.html
What do you want to do?

i need to make a neat table to organize my data
. I understand that you want to create a table.

Then,
The data needs to be read in using cin, or infile.
. I also understand that you are talking about the data to file in the table. And infile means that you could also read from an external text file.

If so, then,
The blanks represent where i would like to read in the information for the first three columns
. So now which table are you talking about? Are you now reading from an external file( infile ) or the table you just created?
Topic archived. No new replies allowed.