Question: Two Dimensional Arrays and Nested For Loops APSC 177 Lab 5 1 Introduction Digital Terrain Models (DTM), also called Digital Elevation Models (DEM), are used
Two Dimensional Arrays and Nested For Loops
APSC 177
Lab 5
1
Introduction
Digital Terrain Models (DTM), also called
Digital Elevation Models (DEM), are used in
many civil engineering applications.
DTMs are
created by measuring terrain elevation at
discrete points on a grid. One way to measure
elevation is with satellite radar.
Then
interpolation between grid points is
conducted to increase the resolution of the
model. A number of interpolation algorithms,
ranging from simple to very sophisticated,
have been developed.
In this lab, you will write a C++ program,
making use of for
loops, to interpolate a
matrix (grid) of numbers that represent
elevations.
Pre
-
lab
Pseudocode
Before
you
r
lab class,
write pseudocode
for your proposed program
(see program
specification below)
.
Only write pseudocode for
the code that you write. Do NOT write
pseudocode for the starter code that you are given. Remember that pseudocode is
similar to code but is written in English and is programming language independent.
There are many ways/styles that pseudocode may be writ
ten. The most important
factor that determines whether your pseudocode is good or not is how clearly it
describes what needs to be coded. If your lab marker can easily understand your
pseudocode suc
h that he/she could implement it in
code, then your pseudocode is
good.
You may produce your
pseudocode
on a computer and print it, or, you may
NEATLY your
write your pseudocode
by hand on a piece of paper. Your
pseudocode
is
due at the START
of your lab class and is worth 2
0% of this labs
grade (see the APSC 177
Lab Guide).
Program Specification
We will implement a very simple interpolation algorithm in this lab.
Each interpolated
value
will simply be the arithmetic mean of the closest values around it. Consider a
4
by
4
square
matrix of
numbers as represented by the diagram below.
APSC 177
Lab 5
2
We wish to interpolate between each pair of numbers (both horizontally and vertically)
such that the result is the 7 by 7 matrix below.
We will do the interpolation in steps.
1.
Calculate each interpolated
value represented by a
by calculating the
average of the 4 numbers around it represented by
.
APSC 177
Lab 5
3
2.
Calculate each interpolated value represented by
a
by calculating the
average of the four numbers around it as follows
3.
Calculate each interpolated value represented by a
by calculating the
average of the three numbers around it as follows
Note that the above interpolation algorithm assumes a
starting data
matrix with
minimum
dimensions of
3
by
3
.
In
the Vocareum Lab 5
assignment
you will find starter code that does everything
required EXCEPT calculate the interpolate
d values.
DO NOT change or delete any of the
starter code.
Study the starter code so that you understand it.
Your task is to add code (where indicated by the comments in the starter code) to
calculate the interpolated values.
Your code must be able to ha
ndle a starting square
matrix of
any
size larger than 2 by 2.
Remember to add comments to your code.
Use
one set of
nested
for
loops to calculate
the interpolated values in step
1
. Use two
sets of nested
for
loops to calculate
the interpolated values in step 2 (note the two
two scenarios in step 2).
Use individual
for
loop
s
to calculate the interpolated values
in
each of the
top row
, most lefthand column, most righthand column, and bottom row
(four scenarios in step 3
)
.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
