Please help with two dimensional array reading from file

my program is supposed to read 16 numbers from a file and input them into a two dimensional array. I then have to print a name then four of these numbers, end the line, print a second name then four more numbers, end the line, print a third name then four more numbers, end the line, print a fourth name then end the line. then under each column it's supposed to get the total for the four numbers in that column. at the end of each row, it's supposed to get each of the values in that row and multiply it by another value and display it.

I need help, I'm stuck and can't go past this. Any help is appreciated it, thank you.



#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>

using namespace std;

int main()
{
ifstream infile;
infile.open("myheb.txt");//the text file has 16 numbers

int quant[4][4]; //creates a 4*4 2d array.

for(int x=0; x<4; x++)
{
for(int y=0; y<4; y++)
{
infile>>quant[x][y];

}
}

for(int x=0; x<4; x++) //This loops on the rows.
{

for(int y=0; y<4; y++) //This loops on the columns
{
cout << quant[x][y] << " ";
}
cout << endl;
}

system("pause");
return 0;
}
What is your problem?
when I run the program it doesn't show the numbers in the text file, it only outputs 8 digit numbers. Below is what I'm supposed to do with my program.

These are the prices of the items.
double milk=2.98, bread=.95, ham=10.95, Cheese=13.98;
underneath Milk Bread Ham Cheese are the numbers displayed from the text file being input. I'm supposed to add by category vertically. Then multiply by the price. to get the total$. on the right by each employee I have to get the total money each employee has made.

Milk Bread Ham Cheese Total
------------------------------------------------------------------------------------------------
Bob 10 4 2 4 |
Jesse 15 1 3 7 |
Jacob 9 4 5 1 |
John 5 6 4 3 |
____________________________________________________________
total #: sum items sold Grand Ttl
Total$: sum*price total cash made
Last edited on
Topic archived. No new replies allowed.