Master of Sustainable Real Estate Development Program - Update #3
Program Development 3
-
Upload
moses-okalebo -
Category
Documents
-
view
217 -
download
0
Transcript of Program Development 3
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 1/14
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 2/14
` Jamwa has just inherited Ushs.1000,000. he
decides to place the money in a two year
certificate of deposit paying 9.6% interest,
compounded quarterly. What will be the value of Jamwa¶s investment after two years have passed?
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 3/14
1. What results are we trying to obtain: what is the
required output ?
2. What data are given: What is the input supplied?
3. Do we have enough information to obtain therequired output from the given input ?
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 4/14
Choose variables to represent the given input and
required output
Think of formulas or logical processes that will be
required to carry out in order to get the desiredresults
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 5/14
` Input variables: P: Initial Amount
R: Interest Rate
N: Number of times per year that compounding
takes place T: Number of years the money is invested
Output Variables:
A: Value of the investment after two years
We should use the compound interest formula, A = P(1 + R/N)NT
Note: interest R must be expressed as a decimalnot as a percentage
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 6/14
` In designing the program, give a step-by-stepprocedure for solving the problem. Such a processis called an algorithm.
` Two of the most popular standard formats for presenting the design of the program are f lowcharts and pseudo code
` A f low chart gives a pictorial representation of the design through processing symbols. They are
excellent tools for showing the structure of someprogramming statements and blocks of code
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 7/14
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 8/14
` For our given problem, these tasks are;
1. Assign the given data to the variables (P, R, N
and T)
2. Compute the final Amount ( A) by using thecompound interest formula
3. Print the value A
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 9/14
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 10/14
` Now sit down and, using the design as an outline,
write the statements or code for the program in
any programming language of your choice such as
BASIC, Visual-Basic, C, C++ or Java
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 11/14
//******** This program calculates Jamwa¶s investment **********//import java.io.*;Public Class Jamwa {
Double P = 1000000; final float R=0.096; int N = 4; int T = 2;public static void main(String args[]){
Float A; A = P*(1+R/N)^N*TSystem.out.println(³The value of an Investment of´; P; ³Shillings´);System.out.println(³Invested at a rate of´; R*100; ³Percent´);
System.out.println(³Compounded´; N; ³Times per Year´);System.out.println(³For´; T; ³Years is´);
System.out.println ( A; ³Dollars´);}
}
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 12/14
` Testing the program ensures that it is free of errorsand that it in fact does solve the given problem
` The process of finding and correcting program errors(getting the bugs out) is called debugging.
` Two types of errors that may arise are known assyntax errors and logic errors.
` A syntax error arises as a result of violation of thelanguages¶ rules of statement structure. They can becaused by misspelling or omitting a key word or byfailing to put the statement in the proper format.
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 13/14
` A logic error is one that leads to incorrect results whenthe program is executed, or it may lead to no results atall.
` It can occur due to faulty analysis, faulty design or a
failure to code the program correctly.` Editing a program: Any syntax or logic errors in your
program must be corrected.
` If the program has already been entered, then it has tobe edited to make the change.
` Editing a program is the process of makingmodifications in it for any reason (error related or not)
8/6/2019 Program Development 3
http://slidepdf.com/reader/full/program-development-3 14/14
` Find the volume (v) of a pyramid with square base
45cm on each side (s) and 75cm in height (h).
Use the formula V=s2h/3
` Note:i. Analyze the problem; list all necessary variable.
ii. Design a program using pseudo code or
flowcharts to solve it
iii. Code your program