5. Consider a data file named STORES.DAT, which contains inventory information for four shops. Each line in the
file contains the inventory of five types of merchandize in each store. Write a program to perform the following:
(a) Read the data into a two-dimensional array invent(4,5).
(b) Produce the output shown below, which includes:
- finding the total inventory of all items in each store
- finding the maximum quantity of each item
THE OUTPUT:
ITEMS
,#1 #2 #3 #4 #5 TOTAL
- - - - - - - - - - - - - - - - -
STORE#1 14 0 5 2 16 37
STORE#2 15 20 0 0 5 40
STORE#3 25 0 10 30 20 85
STORE#4 5 3 3 6 0 17
- - - - - - - - - - - - - - - - -
Max Quant 25 20 10 30 20
and all i could get is this i know its wrong but no idea how to make it go right !
# include <iostream>
using namespace std;
int main ()
{
int a[5][6],n=1,sum,max=0,i=0 ,j=0;
for( i ; i<4 ; i++){
sum=0;
cout<<"STORE#"<<n;
n++;
for( j ; j<5 ; j++){
cin>>a[i][j];
sum+=a[i][j];
}
cout<<sum;
}
for( j=0 ; j<5 ; j++)
for(i=0 ; i<4 ; i++){
a[i][j]=max;
if (a[i][j]<max)
max=a[i][j];
cout<<max;
}
return 0;
}