what happens if you change the nummonths and numyears definitions to other values?
CMIS 102 Hands-On Lab Calendar week viii Overview This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the plan description, assay, test plan, and implementation with C code. The instance provided uses sequential, repetition, option statements, functions, strings and arrays. Programme Description This program volition input and store meteorological data into an array. The program volition prompt the user to enter the boilerplate monthly rainfall for a specific region and and so use a loop to cycle through the array and print out each value. The plan should shop upwards v years of meteorological data. Information is collected once per month. The programme should provide the pick to the user of non entering any information. Analysis I volition utilize sequential, selection, and repetition programming statements and an array to store data. I will define a 2-D assortment of Bladder number: Raindata[][] to store the Float values input past the user. To store up to 5 years of monthly information, the array size should be at to the lowest degree v*12 = 60 elements. In a 2D assortment this will be RainData[5][12]. Nosotros can use #defines to set the number of years and months to eliminate hard-coding values. A float number (rain) will also exist needed to input the private rain information. A nested for loop can be used to iterate through the array to enter Raindata. A nested for loop can too be used to impress the data in the array. An array of strings can exist used to store twelvemonth and calendar month names. This will allow a tabular display with labels for the printout. Functions will exist used to split functionality into smaller piece of work units. Functions for displaying the data and inputting the information will exist used. A selection statement volition be used to determine if data should exist entered. Test Program To verify this program is working properly the input values could exist used for testing: Exam Case Input Expected Output ane Enter data? = y ane.ii 2.ii three.3 2.2 10.2 12.ii 2.3 0.4 0.ii 1.1 2.1 year month rain 2011 January 1.twenty 2011 Feb 2.twenty 2011 Mar three.xxx 2011 Apr 2.20 2011 May 10.20 2011 Jun 12.xx 2011 Jul 2.xxx 2011 Aug 0.40 2011 Sep 0.twenty 2011 Oct 1.10 2011 Nov 2.10 2011 Dec 0.twoscore 0.4 one.1 2.two three.3 2.2 10.2 12.2 two.3 0.4 0.2 one.1 two.1 0.four 1.ane 2.2 3.3 2.ii x.2 12.2 2.iii 0.4 0.2 ane.1 2.1 0.four 1.1 two.2 3.three ii.2 ten.2 12.2 2.three 0.4 0.two ane.i 2.1 0.4 1.1 2.2 3.3 two.ii ten.2 12.2 2.3 0.4 0.2 1.1 two.ane 0.4 2012 January one.10 2012 February 2.20 2012 Mar 3.xxx 2012 Apr two.20 2012 May 10.20 2012 Jun 12.20 2012 Jul 2.xxx 2012 Aug 0.forty 2012 Sep 0.20 2012 Oct 1.10 2012 November two.x 2012 Dec 0.twoscore 2013 January 1.10 2013 Feb 2.20 2013 Mar 3.30 2013 April two.20 2013 May ten.20 2013 Jun 12.20 2013 Jul 2.xxx 2013 Aug 0.xl 2013 Sep 0.twenty 2013 Oct 1.10 2013 November 2.10 2013 Dec 0.40 2014 Jan ane.ten 2014 February ii.20 2014 Mar 3.30 2014 April 2.20 2014 May x.20 2014 Jun 12.xx 2014 Jul 2.30 2014 Aug 0.40 2014 Sep 0.twenty 2014 Oct 1.10 2014 November ii.10 2014 Dec 0.forty 2015 Jan one.x 2015 Feb 2.20 2015 Mar 3.30 2015 Apr 2.20 2015 May 10.20 2015 Jun 12.xx 2015 Jul 2.thirty 2015 Aug 0.40 2015 Sep 0.20 2015 Oct 1.ten 2015 Nov 2.10 2015 Dec 0.40 Please attempt the Atmospheric precipitation program again. 2 Enter data? = n No data was input at this time. Please try the Atmospheric precipitation plan again. C Code The following is the C Lawmaking that volition compile in execute in the online compilers. // C lawmaking // This program volition input and shop meteorological data into an array. // Programmer: ENTER YOUR NAME // Date: ENTER Date Plan FINISHED #define NUMMONTHS 12 #ascertain 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] ={"January","February","Mar","April","May","Jun","Jul","Aug","Sep","October","Nov","Dec"}; int main () { char enterData; printf("Do you want to input Precipatation data? (y for yes)\northward"); scanf("%c",&enterData); if (enterData == 'y') { // Call Function to Input data inputdata(); // Call Office to display data printdata(); } else { printf("No data was input at this fourth dimension\n"); } printf("Delight try the Precipitation program once again. \north"); return 0; } // function to inputdata void inputdata() { /* variable definition: */ int yr, month; // Input Data for (twelvemonth=0;year < NUMYEARS; year++) { for (month=0; calendar month< NUMMONTHS; month++) { printf("Enter rain for %d, %d:\north", yr+1, month+1); scanf("%f",&Raindata [year] [calendar month]); } } } // Office to printdata void printdata(){ int twelvemonth, calendar month; // Print data printf ("year\t month\t rain\northward"); for (yr=0;year < NUMYEARS; year++) { for (calendar month=0; month< NUMMONTHS; calendar month++) { printf("%due south\t %s\t %v.2f\n", years[year],months[month], Raindata[year][month]); } } } Setting up the code and the input parameters in ideone.com: You can change these values to whatever valid integer values to match your exam cases. Results from running the programming at ideone.com Learning Exercises for you lot to complete ane. Load the baseline plan into an online compiler, compile it, and run it. Include a screen capture showing the program running. 2. Modify the programme to add together a function to sum the rainfall for each year. (Hint: y'all demand to sum for each twelvemonth. You can practice this using a looping construction). Support your experimentation with screen captures of executing the new code. 3. Enhance the programme to allow the user to enter another meteorological chemical element such equally windspeed (eastward.chiliad. two.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 tabular array with at to the lowest degree 2 distinct exam cases listing input and expected output for the code you created afterward footstep two. five. What happens if you alter the NUMMONTHS and NUMYEARS definitions to other values? Be sure to use both lower and higher values. Describe and implement fixes for any problems if errors results. Support your experimentation with screen captures of executing the new code. Grading guidelines Submission Points Successfully demonstrates execution of this lab with online compiler. Includes a screen capture. 2 Modifies the code to add together a role to sum the rainfall for each year. Support your experimentation with screen captures of executing the new code 2 Enhances the program to permit the user to enter some other meteorological chemical element such as windspeed (e.thou. 2.four mph). Support your experimentation with screen captures of executing the new code. 2 Provides a new examination table with at least 2 singled-out exam cases listing input and expected output for the lawmaking you lot created subsequently stride 2. i Describes what would happen if yous modify the NUMMONTHS and NUMYEARS definitions to other values? Applies both lower and higher values. Describes and implements fixes for any issues if errors results. Support your experimentation with screen captures of executing the new code 2 Document is well-organized, and contains minimal spelling and grammatical errors. 1 Total 10
Source: https://www.coursemerits.com/solution-details/16212/CMIS-102-Hands-On-Lab-Week-8-COMPLETE-SOLUTION
Postar um comentário for "what happens if you change the nummonths and numyears definitions to other values?"