SlideShare a Scribd company logo
1 of 18
1
CMIS 102 Hands-On Lab
Week 8
Overview
This hands-on lab allows you to follow and experiment with the
critical steps of developing a program
including the program description, analysis, test plan, and
implementation with C code. The example
provided uses sequential, repetition, selection statements,
functions, strings and arrays.
Program Description
This program will input and store meteorological data into an
array. The program will prompt the user to
enter the average monthly rainfall for a specific region and then
use a loop to cycle through the array
and print out each value. The program should store up 5 years
of meteorological data. Data is collected
once per month. The program should provide the option to the
user of not entering any data.
Analysis
I will use sequential, selection, and repetition programming
statements and an array to store data.
I will define a 2-D array of Float number: Raindata[][] to store
the Float values input by the user. To store
up to 5 years of monthly data, the array size should be at least
5*12 = 60 elements. In a 2D array this will
be RainData[5][12]. We can use #defines to set the number of
years and months to eliminate hard-
coding values.
A float number (rain) will also be needed to input the individual
rain data.
A nested for loop can be used to iterate through the array to
enter Raindata. A nested for loop can also
be used to print the data in the array.
A array of strings can be used to store year and month names.
This will allow a tabular display with
labels for the printout.
Functions will be used to separate functionality into smaller
work units. Functions for displaying the data
and inputting the data will be used.
A selection statement will be used to determine if data should
be entered.
Test Plan
To verify this program is working properly the input values
could be used for testing:
Test Case Input Expected Output
1 Enter data? = y
1.2
2.2
3.3
2.2
10.2
12.2
2.3
0.4
0.2
1.1
2.1
year month rain
2011 Jan 1.20
2011 Feb 2.20
2011 Mar 3.30
2011 Apr 2.20
2011 May 10.20
2011 Jun 12.20
2011 Jul 2.30
2011 Aug 0.40
2011 Sep 0.20
2011 Oct 1.10
2011 Nov 2.10
2011 Dec 0.40
2
0.4
1.1
2.2
3.3
2.2
10.2
12.2
2.3
0.4
0.2
1.1
2.1
0.4
1.1
2.2
3.3
2.2
10.2
12.2
2.3
0.4
0.2
1.1
2.1
0.4
1.1
2.2
3.3
2.2
10.2
12.2
2.3
0.4
0.2
1.1
2.1
0.4
1.1
2.2
3.3
2.2
10.2
12.2
2.3
0.4
0.2
1.1
2.1
0.4
2012 Jan 1.10
2012 Feb 2.20
2012 Mar 3.30
2012 Apr 2.20
2012 May 10.20
2012 Jun 12.20
2012 Jul 2.30
2012 Aug 0.40
2012 Sep 0.20
2012 Oct 1.10
2012 Nov 2.10
2012 Dec 0.40
2013 Jan 1.10
2013 Feb 2.20
2013 Mar 3.30
2013 Apr 2.20
2013 May 10.20
2013 Jun 12.20
2013 Jul 2.30
2013 Aug 0.40
2013 Sep 0.20
2013 Oct 1.10
2013 Nov 2.10
2013 Dec 0.40
2014 Jan 1.10
2014 Feb 2.20
2014 Mar 3.30
2014 Apr 2.20
2014 May 10.20
2014 Jun 12.20
2014 Jul 2.30
2014 Aug 0.40
2014 Sep 0.20
2014 Oct 1.10
2014 Nov 2.10
2014 Dec 0.40
2015 Jan 1.10
2015 Feb 2.20
2015 Mar 3.30
2015 Apr 2.20
2015 May 10.20
2015 Jun 12.20
2015 Jul 2.30
2015 Aug 0.40
2015 Sep 0.20
2015 Oct 1.10
2015 Nov 2.10
2015 Dec 0.40
Please try the
Precipitation program
again.
2 Enter data? = n
No data was input at
this time.
3
Please try the
Precipitation program
again.
C Code
The following is the C Code that will compile in execute in the
online compilers.
// C code
// This program will input and store meteorological data into an
array.
// Developer: Faculty CMIS102
// Date: Jan 31, XXXX
#define NUMMONTHS 12
#define NUMYEARS 5
#include <stdio.h>
// 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","Oc
t","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 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++) {
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;
4
}
}
}
// 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.2fn",
years[year],months[month],Raindata[year][month]);
}
}
}
Setting up the code and the input parameters in ideone.com:
You can change these values to any valid integer values to
match your test cases.
5
Results from running the programming at ideone.com
6
Learning Exercises for you to complete
1. 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.
2. 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.
3. Prepare a new test table with at least 2 distinct test cases
listing input and expected output for
the code you created after step 2.
4. 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.
Grading guidelines
Submission Points
Successfully demonstrates execution of this lab with online
compiler. Includes a screen capture.
2
Modifies the code to add a function to sum the rainfall for
each year. Support your experimentation with screen
captures of executing the new code
2
Enhances the program to allow the user to enter another
meteorological element such as windspeed (e.g. 2.4 mph).
Support your experimentation with screen captures of
executing the new code.
2
Provides a new test table with at least 2 distinct test cases
listing input and expected output for the code you created
after step 2.
1
Describes what would happen if you change 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
1  CMIS 102 Hands-On Lab  Week 8 Overview Th.docx

More Related Content

Similar to 1 CMIS 102 Hands-On Lab Week 8 Overview Th.docx

GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docxGanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
budbarber38650
 
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docxWalter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
melbruce90096
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
wkyra78
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
estefana2345678
 
Displaying of Digital Clock through digital circuits and through Assembly Lan...
Displaying of Digital Clock through digital circuits and through Assembly Lan...Displaying of Digital Clock through digital circuits and through Assembly Lan...
Displaying of Digital Clock through digital circuits and through Assembly Lan...
IJERA Editor
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]
MomenMostafa
 
IntroductionThis report discusses the programming process whic.docx
IntroductionThis report discusses the programming process whic.docxIntroductionThis report discusses the programming process whic.docx
IntroductionThis report discusses the programming process whic.docx
mariuse18nolet
 

Similar to 1 CMIS 102 Hands-On Lab Week 8 Overview Th.docx (20)

Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 
Write a program that uses nested loops to collect data and calculate .docx
 Write a program that uses nested loops to collect data and calculate .docx Write a program that uses nested loops to collect data and calculate .docx
Write a program that uses nested loops to collect data and calculate .docx
 
Cs 568 Spring 10 Lecture 5 Estimation
Cs 568 Spring 10  Lecture 5 EstimationCs 568 Spring 10  Lecture 5 Estimation
Cs 568 Spring 10 Lecture 5 Estimation
 
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docxGanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
GanttChartGantt ChartVersion 1.7.3© 2006-2014 Vertex42 LLCVert.docx
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
 
2.pdf
2.pdf2.pdf
2.pdf
 
AIRLINE FARE PRICE PREDICTION
AIRLINE FARE PRICE PREDICTIONAIRLINE FARE PRICE PREDICTION
AIRLINE FARE PRICE PREDICTION
 
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docxWalter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
 
Unit3 overview of_c_programming
Unit3 overview of_c_programmingUnit3 overview of_c_programming
Unit3 overview of_c_programming
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
 
1. basics of python
1. basics of python1. basics of python
1. basics of python
 
ESTIMATING HANDLING TIME OF SOFTWARE DEFECTS
ESTIMATING HANDLING TIME OF SOFTWARE DEFECTSESTIMATING HANDLING TIME OF SOFTWARE DEFECTS
ESTIMATING HANDLING TIME OF SOFTWARE DEFECTS
 
Displaying of Digital Clock through digital circuits and through Assembly Lan...
Displaying of Digital Clock through digital circuits and through Assembly Lan...Displaying of Digital Clock through digital circuits and through Assembly Lan...
Displaying of Digital Clock through digital circuits and through Assembly Lan...
 
Comp 122 lab 4 lab report and source code
Comp 122 lab 4 lab report and source codeComp 122 lab 4 lab report and source code
Comp 122 lab 4 lab report and source code
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]
 
IntroductionThis report discusses the programming process whic.docx
IntroductionThis report discusses the programming process whic.docxIntroductionThis report discusses the programming process whic.docx
IntroductionThis report discusses the programming process whic.docx
 
Cmis 102 Effective Communication / snaptutorial.com
Cmis 102  Effective Communication / snaptutorial.comCmis 102  Effective Communication / snaptutorial.com
Cmis 102 Effective Communication / snaptutorial.com
 
Cmis 102 Enthusiastic Study / snaptutorial.com
Cmis 102 Enthusiastic Study / snaptutorial.comCmis 102 Enthusiastic Study / snaptutorial.com
Cmis 102 Enthusiastic Study / snaptutorial.com
 

More from honey725342

NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docxNRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
honey725342
 
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docxNow the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
honey725342
 
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docxNurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
honey725342
 
Now that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docxNow that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docx
honey725342
 
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
NR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docxNR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docx
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
honey725342
 
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docxNURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
honey725342
 
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docxNur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
honey725342
 
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docxNU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
honey725342
 
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
NR631 Concluding Graduate Experience - Scope  Project Managemen.docxNR631 Concluding Graduate Experience - Scope  Project Managemen.docx
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
honey725342
 

More from honey725342 (20)

NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docxNRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
 
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docxNow the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
 
NR224 Fundamentals SkillsTopic Safety Goals BOOK P.docx
NR224 Fundamentals SkillsTopic Safety Goals BOOK P.docxNR224 Fundamentals SkillsTopic Safety Goals BOOK P.docx
NR224 Fundamentals SkillsTopic Safety Goals BOOK P.docx
 
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docxNurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
 
Now that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docxNow that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docx
 
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
NR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docxNR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docx
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
 
Nurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docx
Nurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docxNurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docx
Nurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docx
 
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docxNURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
 
Nurse workforce shortage are predicted to get worse as baby boomers .docx
Nurse workforce shortage are predicted to get worse as baby boomers .docxNurse workforce shortage are predicted to get worse as baby boomers .docx
Nurse workforce shortage are predicted to get worse as baby boomers .docx
 
Now, for the exam itself. Below are 4 questions. You need to answer .docx
Now, for the exam itself. Below are 4 questions. You need to answer .docxNow, for the exam itself. Below are 4 questions. You need to answer .docx
Now, for the exam itself. Below are 4 questions. You need to answer .docx
 
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docxNur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
 
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docxNU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
 
Nurse Working in the CommunityDescribe the community nurses.docx
Nurse Working in the CommunityDescribe the community nurses.docxNurse Working in the CommunityDescribe the community nurses.docx
Nurse Working in the CommunityDescribe the community nurses.docx
 
nursing diagnosis1. Decreased Cardiac Output  related to Alter.docx
nursing diagnosis1. Decreased Cardiac Output  related to Alter.docxnursing diagnosis1. Decreased Cardiac Output  related to Alter.docx
nursing diagnosis1. Decreased Cardiac Output  related to Alter.docx
 
Nursing Documentation Is it valuable Discuss the value of nursin.docx
Nursing Documentation Is it valuable Discuss the value of nursin.docxNursing Documentation Is it valuable Discuss the value of nursin.docx
Nursing Documentation Is it valuable Discuss the value of nursin.docx
 
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
NR631 Concluding Graduate Experience - Scope  Project Managemen.docxNR631 Concluding Graduate Experience - Scope  Project Managemen.docx
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
 
Number 11. Describe at least five populations who are vulner.docx
Number 11. Describe at least five populations who are vulner.docxNumber 11. Describe at least five populations who are vulner.docx
Number 11. Describe at least five populations who are vulner.docx
 
ntertainment, the media, and sometimes public leaders can perpetuate.docx
ntertainment, the media, and sometimes public leaders can perpetuate.docxntertainment, the media, and sometimes public leaders can perpetuate.docx
ntertainment, the media, and sometimes public leaders can perpetuate.docx
 
Now that you have  completed Lesson 23 & 24 and have thought a.docx
Now that you have  completed Lesson 23 & 24 and have thought a.docxNow that you have  completed Lesson 23 & 24 and have thought a.docx
Now that you have  completed Lesson 23 & 24 and have thought a.docx
 
nothing wrong with the paper, my professor just wants it to be in an.docx
nothing wrong with the paper, my professor just wants it to be in an.docxnothing wrong with the paper, my professor just wants it to be in an.docx
nothing wrong with the paper, my professor just wants it to be in an.docx
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Recently uploaded (20)

Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 

1 CMIS 102 Hands-On Lab Week 8 Overview Th.docx

  • 1. 1 CMIS 102 Hands-On Lab Week 8 Overview This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, and implementation with C code. The example provided uses sequential, repetition, selection statements, functions, strings and arrays. Program Description This program will input and store meteorological data into an array. The program will prompt the user to enter the average monthly rainfall for a specific region and then use a loop to cycle through the array and print out each value. The program should store up 5 years of meteorological data. Data is collected once per month. The program should provide the option to the user of not entering any data.
  • 2. Analysis I will use sequential, selection, and repetition programming statements and an array to store data. I will define a 2-D array of Float number: Raindata[][] to store the Float values input by the user. To store up to 5 years of monthly data, the array size should be at least 5*12 = 60 elements. In a 2D array this will be RainData[5][12]. We can use #defines to set the number of years and months to eliminate hard- coding values. A float number (rain) will also be needed to input the individual rain data. A nested for loop can be used to iterate through the array to enter Raindata. A nested for loop can also be used to print the data in the array. A array of strings can be used to store year and month names. This will allow a tabular display with labels for the printout. Functions will be used to separate functionality into smaller work units. Functions for displaying the data and inputting the data will be used. A selection statement will be used to determine if data should be entered.
  • 3. Test Plan To verify this program is working properly the input values could be used for testing: Test Case Input Expected Output 1 Enter data? = y 1.2 2.2 3.3 2.2 10.2 12.2 2.3 0.4 0.2 1.1 2.1 year month rain 2011 Jan 1.20 2011 Feb 2.20
  • 4. 2011 Mar 3.30 2011 Apr 2.20 2011 May 10.20 2011 Jun 12.20 2011 Jul 2.30 2011 Aug 0.40 2011 Sep 0.20 2011 Oct 1.10 2011 Nov 2.10 2011 Dec 0.40 2 0.4 1.1 2.2 3.3 2.2
  • 7. 10.2 12.2 2.3 0.4 0.2 1.1 2.1 0.4 2012 Jan 1.10 2012 Feb 2.20 2012 Mar 3.30 2012 Apr 2.20 2012 May 10.20 2012 Jun 12.20 2012 Jul 2.30 2012 Aug 0.40 2012 Sep 0.20 2012 Oct 1.10
  • 8. 2012 Nov 2.10 2012 Dec 0.40 2013 Jan 1.10 2013 Feb 2.20 2013 Mar 3.30 2013 Apr 2.20 2013 May 10.20 2013 Jun 12.20 2013 Jul 2.30 2013 Aug 0.40 2013 Sep 0.20 2013 Oct 1.10 2013 Nov 2.10 2013 Dec 0.40 2014 Jan 1.10 2014 Feb 2.20 2014 Mar 3.30 2014 Apr 2.20
  • 9. 2014 May 10.20 2014 Jun 12.20 2014 Jul 2.30 2014 Aug 0.40 2014 Sep 0.20 2014 Oct 1.10 2014 Nov 2.10 2014 Dec 0.40 2015 Jan 1.10 2015 Feb 2.20 2015 Mar 3.30 2015 Apr 2.20 2015 May 10.20 2015 Jun 12.20 2015 Jul 2.30 2015 Aug 0.40 2015 Sep 0.20 2015 Oct 1.10
  • 10. 2015 Nov 2.10 2015 Dec 0.40 Please try the Precipitation program again. 2 Enter data? = n No data was input at this time. 3 Please try the Precipitation program again. C Code The following is the C Code that will compile in execute in the online compilers.
  • 11. // C code // This program will input and store meteorological data into an array. // Developer: Faculty CMIS102 // Date: Jan 31, XXXX #define NUMMONTHS 12 #define NUMYEARS 5 #include <stdio.h> // 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","Oc t","Nov","Dec"};
  • 12. 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 timen"); } printf("Please try the Precipitation program again. n"); return 0; }
  • 13. // 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; 4 } } } // Function to printdata void printdata(){
  • 14. // Print data printf ("yeart montht rainn"); for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { printf("%st %st %5.2fn", years[year],months[month],Raindata[year][month]); } } } Setting up the code and the input parameters in ideone.com: You can change these values to any valid integer values to match your test cases. 5
  • 15. Results from running the programming at ideone.com 6 Learning Exercises for you to complete 1. 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. 2. 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. 3. Prepare a new test table with at least 2 distinct test cases listing input and expected output for
  • 16. the code you created after step 2. 4. 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. Grading guidelines Submission Points Successfully demonstrates execution of this lab with online compiler. Includes a screen capture. 2 Modifies the code to add a function to sum the rainfall for each year. Support your experimentation with screen captures of executing the new code 2 Enhances the program to allow the user to enter another meteorological element such as windspeed (e.g. 2.4 mph).
  • 17. Support your experimentation with screen captures of executing the new code. 2 Provides a new test table with at least 2 distinct test cases listing input and expected output for the code you created after step 2. 1 Describes what would happen if you change 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