Prepare new test table with two distinct test cases listing


Assignment: Computer Programming

Use the following code to complete the lab. Include test tables, screen captures and full text of code used and altered.

// C code

// This program will input and store meteorological data into an array.

// Developer:

// Date: Dec 11, 2018

#define NUMMONTHS 12

#define NUMYEARS 5

#include

// function prototypes

void inputdata();

void printdata();

// 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"};

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 display data

printdata();

}

else {

printf("No data was input at this time\n");

}

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++) {

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;

}

}

}

// Function to printdata

void printdata(){

// Print data

printf ("year\t month\t rain\n");

for (int year=0;year < NUMYEARS; year++) {

for (int month=0; month< NUMMONTHS; month++) {

printf("%s\t %s\t %5.2f\n", years[year],months[month],Raindata[year][month]);

}

}

}

Learning Exercises for you to complete

1. Demonstrate you successfully followed the steps in this lab by preparing screen captures of you running the lab as specified in the Instructions above.

2. Modify the program to add a function to sum the rainfall for each year. (Hint: you need to sum for each year. You can do this using a looping structure). Support your experimentation with screen captures of executing the new code.

3. Enhance the program to allow the user to enter another meteorological element such as windspeed (e.g. 2.4 mph). Note, the user should be able to enter both rainfall and windspeed in your new implementation. Support your experimentation with screen captures of executing the new code.

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.

5. What happens if you change the NUMMONTHS and NUMYEARS definitions to other values? Be sure to use both lower and higher values. Describe and implement fixes for any issues if errors results. Support your experimentation with screen captures of executing the new code.

Format your assignment according to the following formatting requirements:

1. The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.

2. The response also include a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.

3. Also Include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Prepare new test table with two distinct test cases listing
Reference No:- TGS02957004

Expected delivery within 24 Hours