The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
I can't figure out the error in this code to save my life. Plz help... I've attached what I've done as well as the homework assignment. Just need help with #3.
Â
TIA!
Â
Â
#define NUMMONTHS 12
#define NUMYEARS 5
#include <stdio.h>
// function prototypes
void inputdata();
void printdata();
void inputwindspeed();
// Global variables
// These are available to all functions
float Raindata[NUMYEARS][NUMMONTHS];
char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"};
char months[NUMMONTHS][12]Â
={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
float sumRainfall[NUMYEARS];
float windspeed[NUMYEARS][NUMMONTHS];
int main ()
{
 char enterData = 'y';
 printf("Do you want to input Precipatation data? (y for yes)n");
 scanf("%c",&enterData);
 if (enterData == 'y') {
  // Call Function to Input data
  inputdata();Â
 // Call Function to input windspeed
 inputwindspeed();
Â
   // Call Function to display data
   printdata();
  }
  else {
   printf("No data was input at this timen");
  }
  printf("Please try the Precipitation program again. n");
  return 0;
}
// function to inputdata
void inputdata() {
 /* variable definition: */
 float Rain=1.0;Â
  // Input Data
  for (int year=0;year < NUMYEARS; year++) {
  sumRainfall[year]=0.0;
   for (int month=0; month < NUMMONTHS; month++) {
     printf("Enter rain for %d, %d:n", year+1, month+1);
     scanf("%f",&Rain);
     Raindata[year][month]=Rain;
     sumRainfall[year] += Rain;
  }
  }
}
Â
// Function for windspeed data input
void inputwindspeed() {
/*variable definition: */
float windspeed = 1.0;
//input data
for (int year=0;year < NUMYEARS; year++) {
for (int month=0;month < NUMMONTHS; month++) {
printf("Enter windspeed for %d, %d:n", year+1, month+1);
scanf("%f",&windspeed);
}
}
}
Â
// Function to printdata
void printdata() {
// Print data
printf ("yeart montht rainn");
for (int year=0;year < NUMYEARS; year++) {
 for (int month=0; month< NUMMONTHS; month++) {
printf("%st %st %5.2ft %5.2fn",Â
years[year],months[month],Raindata[year][month], windspeed[year][month]);Â Â Â Â Â
   }  Â
   //printing sum of rainfall for the year
   printf("Total rainfall for this year: %5.2fn", sumRainfall[year]);
   }
}
}
Attachments:
----------- He-----------llo----------- Si-----------r/M-----------ada-----------m -----------Tha-----------nk -----------you----------- fo-----------r y-----------our----------- in-----------ter-----------est----------- an-----------d b-----------uyi-----------ng -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------. P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll -----------be -----------qui-----------ckl-----------y