softdev

# softdev - CS 241 Introduction to Problem Solving and...

This preview shows pages 1–9. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 241 Introduction to Problem Solving and Programming Fundamentals of Programming The software development process and Input/Output Jan 21, 2005 CS 241 1 Software development Weve seen and practiced some basic tools. Lets apply them in a meaningful way. The software development process: Specification Design Implementation Testing Maintenance Along the way, documentation . . . CS 241 2 Specification A program begins with a specification . What is the program supposed to do? Example: a program to make change, as for a vending machine or cash register. Specification: Given an amount of money, display the number of quarters, dimes, nickels, and pennies needed to make that amount of change with the fewest number of coins. CS 241 3 Design Once we have isolated the problem, we need an algorithm a method for solving it. An algorithm is a set of instructions for solving a problem. To qualify as an algorithm, the instructions must be expressed so completely and so precisely that somebody could follow the instructions without having to fill in any details or make any decisions that are not fully specified in the instructions. (Savitch, 17) CS 241 4 Design An algorithm should be Precise Easy to read by a human Programming language independent Use pseudocode , an informal mixture of English and a programming language. CS 241 5 Design An algorithm for our change-maker in plain English: Find the greatest number of quarters with value less than the amount. Record that number of quarters. Subtract the value of the quarters from the amount. Record the new amount. Find the greatest number of dimes with value less than the (new) amount. Record that number of dimes. Subtract the value of the dimes from the amount. Record the new amount. Find the greatest number of nickels with value less than the amount. Record the number of nickels. Subtract the value of the nickels from the amount. Record the new amount. Record the number of pennies as equal to the amount that is left. Display result CS 241 6 Design The same algorithm in pseudocode: quarters = amount / 25 quartersValue = quarters * 25 amount = amount - quarterValue dimes = amount / 10 dimesValue = dimes * 10 amount = amount - dimesValue nickels = amount / 5 nickelsValue = nickels * 5 amount = amount - nickelsValue pennies = amount print quarters, dimes, nickels, and pennies Now its starting to look like Java. CS 241 7 Documentation and comments Were ready to begin coding. Start by writing documentation , comments in code that the compiler ignores but explain the program to a human....
View Full Document

## This note was uploaded on 04/29/2010 for the course CS 5503 taught by Professor Kaylor during the Spring '10 term at W. Alabama.

### Page1 / 42

softdev - CS 241 Introduction to Problem Solving and...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online