# Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 – 2.1-2.4.

## Presentation on theme: "Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 – 2.1-2.4."— Presentation transcript:

Software Development Method

Assignments Due – Homework 0, Warmup Reading – Chapter 2 – 2.1-2.4

Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement the algorithm 5.Test and verify the completed program 6.Maintain and update the program

Algorithms Step-by-step procedure for solving a problem Be as specific as possible – include all steps Example – laundry

Software Development Method 1.Specify the problem requirements In this class, often done for you 2.Analyze the problem Your job – what are the inputs and outputs 3.Design the algorithm to solve the problem Your job – write it down and turn it in! 4.Implement the algorithm Your job 5.Test and verify the completed program Your job – this is the most time consuming part Go back to step 4 if your program fails the tests 6.Maintain and update the program Always assume you will reuse your code at some point

Calculate Tax on an Item Problem Analysis Algorithm design Implementation Testing Maintenance

/* * A program to calculate tax and total cost. */ #include /* printf, scanf definitions */ #define TAX_RATE.05 //constant rate of taxation int main (void) { double cost, tax, total; //spaces for item cost, tax, and total cost /* get the cost of the item */ printf("Enter cost of item: "); scanf("%lf", &cost); /* calculate the tax */ tax = cost * TAX_RATE; // calculate the total cost total = cost + tax; /* display the result */ printf("The tax on your item is \$%5.2lf.\n", tax); printf("The total cost of your purchase is \$%5.2lf.\n", total); return(0); }

Heading Indicates what the program does –You will get a format to follow in lab Comments –/* … */ –// to the end of the line /* * A program to calculate tax and total cost. */

Preprocessor Directives #include – use a particular library #define – replace TAX_RATE with.05 in the program #include /* printf, scanf definitions */ #define TAX_RATE.05 //constant rate of taxation

Function Header All programs must have a main function void – inputs int – outputs main should always look like this int main (void) {

Syntax outline of main should always look like this int main (void) { body return(0); }

Variable Declaration Creates three spaces in the computer’s memory to hold numbers double –type – space will hold a number with a decimal –name – variables given unique identifiers Reserved words –words with special meaning (double, int, void, return) Identifiers –letters, digits, and underscores –cannot begin with a digit –cannot be a reserved word –cannot conflict double cost, tax, total; //spaces for item cost, tax, and total cost

Input and Output Standard identifiers printf – print to the screen scanf – read from the keyboard (standard input) –%lf – read a long float –store it in the cost space –& – address (instead of value) printf("Enter cost of item: "); scanf("%lf", &cost);

Calculation Typical math symbols –(+, -, *, /) = - assignment, not equality! alternative (if we don’t need tax alone) total = cost + (cost * TAX_RATE); /* calculate the tax */ tax = cost * TAX_RATE; // calculate the total cost total = cost + tax;

Display Results printf – formatted print replace “%lf” with number 5.2 – precision \n – escape character (newline) printf("The tax on your item is \$%5.2lf.\n", tax); printf("The total cost of your purchase is \$%5.2lf.\n", total);

Download ppt "Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 – 2.1-2.4."

Similar presentations