Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 Software Development Method

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

3 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

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

5 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

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

7 /* * 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); }

8 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. */

9 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

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

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

12 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

13 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);

14 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;

15 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


Ads by Google