HELP!!

May 29, 2015 at 10:56am
The rainfall figures in mm are available for each day of the past four weeks. Write a function generateReport() that displays the total rainfall for each week and the most wettest day. The function takes as parameter a two-dimensional array named, figures of size 4 x 7, that contains rainfall figures in which each row represent a week and each column represent a day.

For example, if the array contains the following rainfall data:

Days
0 1 2 3 4 5 6
Week 0 3 0 0 7 8 21 0
Week 1 0 1 1 0 0 0 4
Week 2 9 6 7 0 0 0 0
Week 3 0 0 0 0 0 0 1

Then the output of the function should be displayed as follows:



Week Rainfall data Total
1 3 0 0 7 8 21 0 39
2 0 1 1 0 0 0 4 6
3 9 6 7 0 0 0 0 22
4 0 0 0 0 0 0 1 1

The wettest day was day 6 in week 1.


Write a main program to create a 2d array and ask the user to enter rainfall data the call function generateReport to print the report on screen


can anyone solve this please??
May 29, 2015 at 10:57am
Yeah we can do it, why don't you just try it, it's quite easy if you have 10 minutes
Last edited on May 29, 2015 at 10:57am
May 29, 2015 at 10:58am
#include<iostream>
using namespace std;
void generatereport (int x[][7],int row)
{
int sum,wet=0,wek,maxd;
cout<<"Week Rainfall Total"<<endl;
for (int i=0;i<row;i++)
{
sum=0;
cout<<i+1<<"\t";
for (int j=0;j<7;j++)
{
cout<<x[i][j]<<" ";
sum+=x[i][j];
if (x[i][j]>wet)
{
wet=x[i][j];
wek=i;
maxd=j;
}
}
cout<<" \b\t"<<sum<<endl;
}
cout<<endl<<"The wettest day was day "<<maxd+1<<" in week "<<wek+1<<endl;
}
int main()
{
int x[4][7]={{3,0,0,7,8,21,0},{0,1,1,0,0,0,4},{9,6,7,0,0,0,0},{0,0,0,0,0,0,1}};
generatereport(x,4);
system ("pause");
return 0;
}

i did this but im not sure
May 29, 2015 at 11:01am
how can you not be sure?
Did you not run it?
May 29, 2015 at 11:02am
im trying to run it but it says source file not compiled..
May 29, 2015 at 11:04am
do you have Visual Studio or something like this?

also: why are there values for 8 days?
Week 0 3 0 0 | 7 8 21 0
Week 1 0 1 1 | 0 0 0 4
Week 2 9 6 7 | 0 0 0 0
Week 3 0 0 0 | 0 0 0 1
May 29, 2015 at 11:06am
its' week 0
week 1
week 2
week 3

they are 7 days not 8

and no i do not have visual studio just the dev c++ program
May 29, 2015 at 11:13am
its' week 0
week 1
week 2
week 3

ops

and no i do not have visual studio just the dev c++ program

press F9, that should compile and run the programm
May 29, 2015 at 11:24am
i did it says "g++.exe has stopped working"

what should i do?
May 29, 2015 at 11:37am
get a better idea/compiler. try visual studio express.
May 29, 2015 at 11:42am
get a better idea/compiler

this, i never liked devc++ because it's ugly and doesn't provide much
try QtCreator, it's awesome and even provides a GUI designer
https://www.qt.io/download-open-source/

well, your programm works, just test it online in cpp.sh for the time being:
http://cpp.sh/9xuz
Last edited on May 29, 2015 at 11:47am
May 29, 2015 at 12:30pm
anyone has the program and check it for me please?
May 29, 2015 at 12:32pm
click on the last link I posted before:
http://cpp.sh/9xuz
May 29, 2015 at 1:00pm
checked it thanks a lot
May 29, 2015 at 1:25pm
you're welcome
Topic archived. No new replies allowed.