CMIS 102 Hands-On Lab

Similar documents
CS Programming I: Arrays

High Performance Computing

Data Types. 9. Types. a collection of values and the definition of one or more operations that can be performed on those values

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

This report is based on sampled data. Jun 1 Jul 6 Aug 10 Sep 14 Oct 19 Nov 23 Dec 28 Feb 1 Mar 8 Apr 12 May 17 Ju

Excel Functions & Tables

C Structures, Unions, Bit Manipulations, and Enumerations

Programming for Engineers Structures, Unions

Arrays III and Enumerated Types

Section 1.2: What is a Function? y = 4x

Asks for clarification of whether a GOP must communicate to a TOP that a generator is in manual mode (no AVR) during start up or shut down.

Data Types H&K Chapter 7. Instructor - Andrew S. O Fallon CptS 121 (October 17, 2018) Washington State University

Lecture 6. Drinking. Nested if. Nested if s reprise. The boolean data type. More complex selection statements: switch. Examples.

software.sci.utah.edu (Select Visitors)

Type Definition. C Types. Derived. Function Array Pointer Structure Union Enumerated. EE 1910 Winter 2017/18

Lecture 14. Dynamic Memory Allocation

ECSE 321 Assignment 2

Project 1 System Calls

Lecture Notes: ESC 101

Syntax and Variables

C: How to Program. Week /Mar/05

All King County Summary Report

Friday, February 3, Lab Notes. Functions in C Arrays as parameters Pass by value vs pass by reference Programs 1 and 2

FREQUENTLY ASKED QUESTIONS

BANGLADESH UNIVERSITY OF PROFESSIONALS ACADEMIC CALENDAR FOR MPhil AND PHD PROGRAM 2014 (4 TH BATCH) PART I (COURSE WORK)

3. EXCEL FORMULAS & TABLES

History. used in early Mac development notable systems in Pascal Skype TeX embedded systems

Seattle (NWMLS Areas: 140, 380, 385, 390, 700, 701, 705, 710) Summary

Seattle (NWMLS Areas: 140, 380, 385, 390, 700, 701, 705, 710) Summary

Seattle (NWMLS Areas: 140, 380, 385, 390, 700, 701, 705, 710) Summary

HPE Security Data Security. HPE SecureData. Product Lifecycle Status. End of Support Dates. Date: April 20, 2017 Version:

If Case Loop Next Exit

What you learned so far. Loops & Arrays efficiency for statements while statements. Assignment Plan. Required Reading. Objective 2/3/2018

More Binary Search Trees AVL Trees. CS300 Data Structures (Fall 2013)

and function calls (including call-by-reference parameters and global variables), but no decision or repetition instructions.

ICT PROFESSIONAL MICROSOFT OFFICE SCHEDULE MIDRAND

More BSTs & AVL Trees bstdelete

OBJECT ORIENTED PROGRAMMING USING C++

CSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1

typedef int Array[10]; String name; Array ages;

Recursion Enums. Basics of Programming 1. Department of Networked Systems and Services G. Horváth, A.B. Nagy, Z. Zsóka, P. Fiala, A.

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.

CpSc 1111 Lab 4 Formatting and Flow Control

Create Designs. How do you draw a design on a coordinate grid?

Lab 2: Structured Program Development in C

Introduction to Computer Programming for Non-Majors

Monthly SEO Report. Example Client 16 November 2012 Scott Lawson. Date. Prepared by

n Group of statements that are executed repeatedly while some condition remains true

SCI - software.sci.utah.edu (Select Visitors)

ADVANCED SPREADSHEET APPLICATIONS (07)

Operator overloading: extra examples

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function

Introduction. Structures, Unions, Bit Manipulations, and Enumerations. Structure. Structure Definitions

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

Definition: Data Type A data type is a collection of values and the definition of one or more operations on those values.

Dept. of CSE, IIT KGP

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga

Decision Making -Branching. Class Incharge: S. Sasirekha

AMCAT Automata Coding Sample Questions And Answers

COURSE LISTING. Courses Listed. with SAP Hybris Marketing Cloud. 24 January 2018 (23:53 GMT) HY760 - SAP Hybris Marketing Cloud

Introduction to Programming

Chapter 5: Control Structures

COURSE LISTING. Courses Listed. Training for Database & Technology with Modeling in SAP HANA. 20 November 2017 (12:10 GMT) Beginner.

BSM540 Basics of C Language

Sand Pit Utilization

Grade 4 Mathematics Pacing Guide

Automatic Renewal Using DIY Technology to Create an Improved Patron Experience

CIMA Asia. Interactive Timetable Live Online

4. ENCOUNTER DATA PROCESSING PROCEDURES A. General Information

CSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU

APPENDIX E2 ADMINISTRATIVE DATA RECORD #2

CMR India Monthly Mobile Handset Market Report. June 2017

Undergraduate Admission File

Annex A to the DVD-R Disc and DVD-RW Disc Patent License Agreement Essential Sony Patents relevant to DVD-RW Disc

Lecture 10: Boolean Expressions

BBM#101# #Introduc/on#to# Programming#I# Fall$2013,$Lecture$12$

Instructor training course schedule v3 Confirmed courses due completion by 31 st July 2019

Polycom Advantage Service Endpoint Utilization Report

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

Functions. Lab 4. Introduction: A function : is a collection of statements that are grouped together to perform an operation.

Polycom Advantage Service Endpoint Utilization Report

CSE 341 Section Handout #6 Cheat Sheet

Questions? Static Semantics. Static Semantics. Static Semantics. Next week on Wednesday (5 th of October) no

Functions and Recursion

Fundamental of Programming (C)

Structured Program Development in C

2

Omega Engineering Software Archive - FTP Site Statistics. Top 20 Directories Sorted by Disk Space

2

2

AIMMS Function Reference - Date Time Related Identifiers

ECE264 Fall 2013 Exam 1, September 24, 2013

CS1100 Introduction to Programming

File Handling in C. EECS 2031 Fall October 27, 2014

UAE PUBLIC TRAINING CALENDAR

NCC Cable System Order

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1

Technical Questions. Q 1) What are the key features in C programming language?

CIMA Asia. Interactive Timetable Live Online

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

Transcription:

CMIS 10 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 -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*1 = 60 elements. In a D array this will be RainData[5][1]. We can use #defines to set the number of years and months to eliminate hardcoding 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 year month rain 1. 011 Jan 1.0 011 Feb 0 011 Mar 0 011 Apr 0 011 May 0 1 011 Jun 10 011 Jul 0 011 Aug 0 011 Sep 0 011 Oct 0 011 Nov 0 011 Dec 0 1

1 1 1 1 01 Jan 0 01 Feb 0 01 Mar 0 01 Apr 0 01 May 0 01 Jun 10 01 Jul 0 01 Aug 0 01 Sep 0 01 Oct 0 01 Nov 0 01 Dec 0 013 Jan 0 013 Feb 0 013 Mar 0 013 Apr 0 013 May 0 013 Jun 10 013 Jul 0 013 Aug 0 013 Sep 0 013 Oct 0 013 Nov 0 013 Dec 0 014 Jan 0 014 Feb 0 014 Mar 0 014 Apr 0 014 May 0 014 Jun 10 014 Jul 0 014 Aug 0 014 Sep 0 014 Oct 0 014 Nov 0 014 Dec 0 015 Jan 0 015 Feb 0 015 Mar 0 015 Apr 0 015 May 0 015 Jun 10 015 Jul 0 015 Aug 0 015 Sep 0 015 Oct 0 015 Nov 0 015 Dec 0 Please try the Precipitation program again. Enter data? = n No data was input at this time.

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 CMIS10 // Date: Jan 31, XXXX #define NUMMONTHS 1 #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] = {"011","01","013","014","015"; char months[nummonths][1] ={"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; 3

// 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.f\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 any valid integer values to match your test cases. 4

Results from running the programming at ideone.com 5

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.. Enhance the program to allow the user to enter another meteorological element such as windspeed (e.g..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 distinct test cases listing input and expected output for the code you created after step. 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 Successfully demonstrates execution of this lab with online compiler. Includes a screen capture. 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 Enhances the program to allow the user to enter another meteorological element such as windspeed (e.g..4 mph). Support your experimentation with screen captures of executing the new code. Points Provides a new test table with at least distinct test cases 1 listing input and expected output for the code you created after step. 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. Document is well-organized, and contains minimal spelling 1 and grammatical errors. Total 10 6