You are on page 1of 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 Jamwas investment after two years have passed?

1.

2. 3.

What results are we trying to obtain: what is the required output? What data are given: What is the input supplied? Do we have enough information to obtain the required output from the given input?

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 desired results

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 decimal not as a percentage
`

In designing the program, give a step-by-step procedure for solving the problem. Such a process is called an algorithm. Two of the most popular standard formats for presenting the design of the program are flow charts and pseudo code A flow chart gives a pictorial representation of the design through processing symbols. They are excellent tools for showing the structure of some programming statements and blocks of code

` `

Pseudo code closely resembles the outlining process familiar from essay writing. Short English like phrases are used to describe the design. In our example we will use both of these methods. In using Pseudo code we have to ask ourselves; what fundamental tasks we have to perform in order to create the program.

` 1.

2.

3.

For our given problem, these tasks are; Assign the given data to the variables (P, R, N and T) Compute the final Amount (A) by using the compound interest formula Print the value A

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

//******** This program calculates Jamwas 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*T System.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); } }

` ` ` `

Testing the program ensures that it is free of errors and 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 as syntax errors and logic errors. A syntax error arises as a result of violation of the languages rules of statement structure. They can be caused by misspelling or omitting a key word or by failing to put the statement in the proper format.

` ` ` `

A logic error is one that leads to incorrect results when the program is executed, or it may lead to no results at all. 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 to be edited to make the change. Editing a program is the process of making modifications in it for any reason (error related or not)

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
`

You might also like