Question
What is not right with this code? I added temperature to the original and it will not run correctly now. 4. Prepare a new test
What is not right with this code? I added temperature to the original and it will not run correctly now.
4. Prepare a new test table with at least 2 distinct test cases listing input and expected output for the new code you created allowing the user to enter another meteorological element.
#define NUMMONTHS 12 #define NUMYEARS 5 #include
for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { printf("Enter WindSpeed for %d, %d:(mph) ", year+1, month+1); scanf("%f",&Wind); WindSpeed[year][month]=Wind; } }
for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { printf("Enter Temperature for %d, %d:(degrees) ", year+1, month+1); scanf("%f",&Temperature); Temperature[year][month]=Temperature; } } } // Function to printdata void printdata(){ // Print data printf ("year\t month\t rain\t wind "); for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { printf("%s\t %s\t %5.2f\t %5.2f ", years[year],months[month],Raindata[year][month],WindSpeed[year][month]); } } printf ("sum the rainfall for each year "); printf ("year\t rain(sum) "); float sumRain = 0.0; for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { sumRain += Raindata[year][month]; } printf("%s\t %5.2f ", years[year],sumRain); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started