Programming at a high level
Developing a Computer Program Programmer Writes program in source code (VB or other language) Compiler Converts source code to machine language code Linker Combines machine language with libraries & converts them to an executable module Interpreter Converts source code to machine language and executes one line at a time CompilerLink/load Executable module Source code Machine language Output Input data High-level language Low-level Language
Model Building Process Problem identification Important elements to be modeled Relations and interactions between them Degree of accuracy Conceptualization and development Mathematical description Type of model Numerical method - computer code Grid, boundary & initial conditions Calibration Estimate model parameters Model outputs compared with actual outputs Parameters adjusted until the values agree Verification Independent set of input data used Results compared with measured outputs
Programming Process Grace M. Hopper First “Bug” Algorithm Design (underlying logic of program) Program Composition Debug & test (error free & reliable) Program Documentation Program Maintenance
Programming Tools Tools to convert algorithms into computer programs Algorithm: Step-by-Step procedure for solving a problem Example Problem: You write a letter. To mail it, you must decide how much postage to put on the envelop. Rule of Thumb: One stamp for every 5 sheets of paper. Algorithm: see next slide
Algorithm 1. Request the number of sheets of paper; call this “Sheets” 2. Divide Sheets by 5 3. Round the quotient up to the next highest whole number; call it “Stamps” 4. Reply with the number Stamps 5. Example: INPUT (16) Processing Output (4)
Flowchart Symbols Flow Line Start/Stop Input/Output Processing Decision
Stamp Problem Program: Determine the proper number of stamps for a letter Read sheets Set the number of stamps to sheets/5 Round the number of stamps up to the next whole number Display the number of stamps Start Read sheets Set stamps = sheets/5 Round stamps up To next whole # Display stamps End Input Processing Output Flowchart Pseudocode
Decisions If condition is true, then Process step(s) 1 Else Process step(s) 2 End if Is condition True? Process Step(s) 1 Process Step(s) 2 No Yes Flowchart Pseudocode
Average Grade Problem Start Sum=0 Count = 0 Input Grade More grades? Sum = Sum + Grade Count = Count + 1 Average = Sum/Count Stop No Yes Flowchart Pseudocode BEGIN Average Grade sum=0 count = 0 DO WHILE grade > 0 sum = sum + grade count = count +1 END DO average = sum/count END Average Grade