300 likes | 459 Vues
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle. The program development life cycle is a model that describes the stages involved in a program development project, from an initial feasibility study through maintenance of the completed program.
E N D
Program Development Life Cycle • The program development life cycle is a model that describes the stages involved in a program development project, from an initial feasibility study through maintenance of the completed program. • The program development life cycle can be summarized as: • Analysis • Design • Testing • Implementation • Maintenance
Analysis In this phase the existing system is evaluated. Deficiencies are identified. This can be done by interviewing users of the system and consulting with support personnel. The new system requirements are defined. In particular, the deficiencies in the existing system must be addressed with specific proposals for improvement.
Design The proposed system is designed. Plans are laid out concerning the hardware, operating systems, programming, communications and security issues. The new system is developed. The new components and programs must be obtained and installed.
Testing Once the new system is developed, all aspects of performance must be tested. Testing should ensure that the system not only responds correctly to valid data but also deals with invalid data. If necessary, adjustments can be made at this stage.
Implementation The new system is put into use. The new system can be phased in, according to application or location and the old system gradually replaced. In some cases, it may be more cost-effective to shut down the old system and implement the new system all at once. Users of the new system must be trained in its use.
Maintenance Once the new system is up and running for a while, it should be exhaustively evaluated. Maintenance must be kept rigorously at all times. Users of the system should be kept up-to-date concerning the last modifications and procedures.
Analyzing the problem • In order to write a program to accomplish a certain task you must analyze the task as a sequence of instructions that can be performed by the computer. • These instructions can be divided into three main parts: • Input and Storage Instructions • Processing Instructions • Output Instructions
Input and Storage instructions These instructions allow data to be accepted by the computer. The input is information that is needed by the computer to solve the problem. Words such as ‘Enter’, ‘Input’ and ‘Read’ within problem statements usually indicate what data the computer requires.
Input and Storage instructions • Example 1 • What are the input and storage instructions here? • Read the price of an item and calculate the discount of 10%. • Enter the name and year of birth of a person and calculate the person’s age. • Input the length of a side of a square tile and find the area.
Input and Storage instructions • Let’s analyze these instructions to determine the • inputs and what we need to store. • Read and store the price of an item • 2) Enter the name and year of a birth of a person • 3) Input the length of the side of a square tile
Processing instructions These instructions manipulate the input data. They involve calculations that is, mathematical operations (e.g. addition, subtraction, multiplication and division), repeating instructions, selecting instructions and comparison instructions. They also include commands and constructs.
Processing instructions A command is a word that instructs the computer what must be done to accomplish a specific task. Commands are specific to a particular programming language: for example WRITE, PRINT, READ, INPUT etc.
Processing instructions A construct is a group of instructions that work together with commands to accomplish a specific task. An example is the ‘IF-THEN’ construct: Example: IF a < 10 THEN READ Num ENDIF
Processing instructions Problem statements that contain the words ‘calculate’, ‘compute’, ‘convert’, ‘add’, ‘sum’, ‘subtract’, ‘minus’, ‘multiply’, ‘divide’, ‘percentage’, ‘average’, indicate what needs to be done. Problem statements can also imply what needs to be processed by looking at what results are required for output. For example : Print the area of the room’.
Processing instructions • Example 2 • What are the processing instructions here? • Read the price of an item and calculate the new price after a 10% discount. • 2) Enter a temperature in degrees Celsius and convert it to degrees Fahrenheit. • 3) Input the name and year of birth and compute and print the age of a person.
Processing instructions • Let’s analyze these instructions to determine • what we need to process. • Calculate the new price after a 10% discount. • 2) Convert it to degrees Fahrenheit. • 3) Compute the age of a person.
Processing instructions Comparison statements and repeat statements Comparison/selection/decision statements involve determining whether a condition is true or false in order to perform a set of instructions.
Processing instructions Comparison statements and repeat statements For example: Read the weekly hours worked by an employee. If the hours worked are greater than 40, then calculate overtime salary at 1.5 times the standard hourly rate of $8.50, for those over 40. The condition that is checked is the number of hours worked to determine if it is more than 40.
Processing instructions Comparison statements and repeat statements Repeat statements/loopings/iterations are used when a problem has to be done a number of times. For example: Read the marks for three subjects, English, Maths and Spanish, for each student; find the average mark of each student in a class of 15, over the three subjects. The process of finding the average for the three subjects has to be repeated 15 times.
Output instructions • These instructions allow information to be • displayed on the screen. Problem statements that • include key words like ‘print’, ‘output’, • ‘display’, ‘return’ and ‘write’, indicate what data • should be output to the screen. • Example 3 • What are the output statements here? • Enter the name and year of birth of a person and compute and display the age of the person. • Write an algorithm to print a conversion table of °C to °F, 10°C to 20°C inclusive.
Output instructions • Let’s analyze these instructions to determine what • we need to output. • Display the age of the person • 2) Print a conversion table
Examples Let’s analyze a few problems. Example 4 Write a program to enter the base and the height of a triangle and find and print the area.
Examples Example 5 Write a program to read the temperature in degrees Celsius (°C) and convert it to degrees Fahrenheit (°F) where F=32+(9C/5). Output the temperature in degrees Celsius and Fahrenheit.
Examples Example 6 Write a program to read the answer to the sum 10*12. (The answer is 120.) Return the comment “Correct” if the answer is right and “Incorrect” if the answer is wrong.
Examples Example 7 Write a program that reads the result of 10 games played by a team and find the percentage of games won by the team. Output the percentage games won.
Examples Example 8 A school has a house system implemented. Points are awarded to a house based on the performance of its members. 1st place – 4 points, 2nd place – 3 points, 3rd place – 2 points, 4th place - 1 point, and last place – no points awarded. Read the names of 10 members of the Aripo house and the place they came on the events; calculate and print the total points awarded to the house.