GNG1106 Winter 2016 - Assignment 3 | Complete Solution
- HomeworkExp
- Rating : 24
- Grade : A+
- Questions : 0
- Solutions : 287
- Blog : 1
- Earned : $9883.30
GNG1106 Winter 2016 - Assignment 3
Available: Feb 1, 2016
Due: Sun, Feb 7, 2016, midnight, for students in Tuesday and Thursday Labs
Tues, Feb 9, 2016, midnight, for students in the Saturday lab
Instructions
This assignment is to be done INDIVIDUALLY. Follow the instructions in the GNGBlackboard document that describes how to submit assignments through the Blackboard. The following are specific instructions for this assignment:
· You will need to submit your assignment electronically to Blackboard.
· The questions are provided in both PDF and Word files. You may use the Word file to enter your answers in the document. An rtf file is also provided so that you may edit the file with a word processor other than Word. Submit your answers as a PDF file. Word processor applications offer the possibility of saving the file in a PDF file.
· It is NOT permitted to use branches and loops that have not yet been covered in the lectures.
· Do submit the programs developed for question 4 (also insert the code in your assignment document).
· Zip your PDF document and the C source file in a zip file with the name A1_xxxxxx.zip where xxxxxx is your student number and submit the zip file to BBL.
Ø Do start the assignment soon and do not wait until the last minute. You will be more efficient with a number of smaller efforts over a few weeks before the deadline than one large effort just before the deadline.
Marking Scheme (total 40 marks)
- Question 1: 5 marks
- Question 2: 10 marks
- Question 3: 10 marks
- Question 4: 15 marks
Question 1 (5 marks)
In the following programming model, show how the given C program affects the contents of the working memory.
· Show how the array and variable occupy space in the working memory.
· Show how the array is initialized.
·
varName
?, 2, 6, 4, 10
Show the values are assigned the variable and elements in the array by the assignment instructions. Be sure to show all values that are assigned and replaced. Record successive assignments to variables/parameters as follows the ? shows an unknown value:
Note: You do NOT need to show how the CPU interacts with memory.
Question 2 (10 marks)
In the following programming model, show how the given C program affects the contents of the working memory.
· Show how the array and variables occupy space in the working memory.
· Show how the array is initialized.
·
varName
?, 2, 6, 4, 10
Show the values are assigned the variables and elements in the array by the assignment instructions. Be sure to show all values that are assigned and replaced. Record successive assignments to variables/parameters as follows (the ? shows an unknown value).
· For the pointer variable, use adr1, adr2, adr3, etc for values assigned to the pointer and draw a line showing to which location in memory the address is referring.
ptrName
?, adr1, adr2
Note: You do NOT need to show how the CPU interacts with memory.
Question 3 (10 marks)
In the following programming model, show how the given C program affects the contents of the working memory.
· Show how the array and variables occupy space in the working memory.
· To make the representation of the structure values practical, draw the character array “type” horizontally instead of vertically.
· Show how the structure values in the array are initialized.
·
varName
?, 2, 6, 4, 10
Show the values are assigned to the variables by the assignment instructions (don’t forget the pointer variable). Be sure to show all values that are assigned and replaced. Record successive assignments to variables/parameters as follows (the ? shows an unknown value).
· For the pointer variable, use adr1, adr2, adr3, etc for values assigned to the pointer and draw a line showing to which location in memory the address is referring.
ptrName
?, adr1, adr2
Note: You do NOT need to show how the CPU interacts with memory.
Question 4 (15 marks)
The following sections provide an organized presentation of the problem to solve with a computer program. It will allow the user to find the channel velocity for one of four channels.
· In your design, use a C structure as follows:
o One structure with members that contain values for the open channel, that is, member variables n (roughness), slope (value of S), width (value of B), and depth (value of H). Do define the type CHANNEL for this structure.
o Create an array of structures of type CHANNEL. The array should contain 4 elements. You can initialise the array when declaring it; see question 3 for an example on how to initialise the array of structure variables.
o DO NOT include the velocity in the structure. Calculate the velocity only after the user has selected the channel.
o Prompt the user for a channel number (from 1 to 4) that can be used to determine the index into the structure array.
The answer to this question provide:
1) The design in step three (start with your design before you code).
2) The source code to your program in a C file (also insert the source code into the step 4 section)
3) Insert the output for each test case in Step 5)
Step 1: Problem Statement
Develop a program presents the characteristics of four rectangular channels and prompt the user to select one of the channels. Prompt the user to select the channel, calculate the channel velocity and shown the results to the user.
Step 2: Background
The velocity in a rectangular open channel can be calculated using Manning’s equation
,
where U is the velocity in m/s,
S is the channel slope
n is the roughness coefficient
B is the width in m
H is the depth in m
0.035The following data is available for five channels:
n
Slope
(S)
Width (B)
Depth (H)
0.035
0.0001
10.0
2.0
0.020
0.0002
8.0
1.0
0.015
0.0010
20.0
1.5
0.030
0.0007
24.0
3.0
Step 3: Test Cases and Software Design
The following table provides test cases that can be used for testing the software.
n
Slope (S)
Width (B)
(m)
Depth (H)
(m)
Velocity (U)
(m/s)
0.035
0.0001
10
2.00
0.1438
0.02
0.0002
8
1.00
0.6094
0.015
0.0010
20
1.50
1.4657
0.03
0.0007
24
3
0.3654
Design:
Data Structures:
Variables
Symbolic Constants
Logic/Strategies
Step 4: Implementation
Develop the program using CodeBlocks. Insert your code here.
Step 5: Software Testing and Verification
Test the program using the values provided in the table provides in Step 3. Insert the output from your program for each test case here.
[Solved] GNG1106 Winter 2016 - Assignment 3 | Complete Solution
- This Solution has been Purchased 2 time
- Submitted On 07 Feb, 2016 04:28:42
- HomeworkExp
- Rating : 24
- Grade : A+
- Questions : 0
- Solutions : 287
- Blog : 1
- Earned : $9883.30