Stepwise Refinement
Lecture 6 CGS 3416 Spring 2017 February 6, 2017
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 1 / 17
Stepwise Refinement Lecture 6 CGS 3416 Spring 2017 February 6, - - PowerPoint PPT Presentation
Stepwise Refinement Lecture 6 CGS 3416 Spring 2017 February 6, 2017 Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 1 / 17 Programming is about Problem Solving Algorithm - a finite sequence of steps to perform a specific task To solve
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 1 / 17
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 2 / 17
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 3 / 17
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 4 / 17
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 5 / 17
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 6 / 17
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 7 / 17
1 Declare and initialize variables 2 Input grades (prompt user and allow input) 3 Compute class average and output result Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 8 / 17
1 add the grades 2 count the grades 3 divide the sum by the count
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 9 / 17
1 Declare and initialize variables 2 Input grades -- count and add them as they are input 3 Compute class average
1 prompt user to enter a grade (give them needed info,
2 allow user to type in a grade (store in a variable) 3 add the grade into a variable used for storing the sum 4 add 1 to a counter (to track how many grades) Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 10 / 17
1
2 allow user to type in a grade (store in a variable) 3 add the grade into a variable used for storing the sum 4 add 1 to a counter (to track how many grades)
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 11 / 17
1 prompt user to enter a grade (give them needed info,
2 allow user to type in a grade (store in a varaible) 3 if the entered value is a GRADE (not the sentinel
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 12 / 17
1 a grade variable (to store user entry) 2 a sum variable (initialized to 0) 3 a counter (initialized to 0)
1 divide sum by counter and store result 2 print result Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 13 / 17
2 a sum variable (initialized to 0) 3 a counter (initialized to 0) Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 14 / 17
1 prompt user to enter a grade (give them needed info,
2 allow user to type in a grade (store in a varaible) 3 if the entered value is a GRADE (not the sentinel
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 15 / 17
2 print result Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 16 / 17
Lecture 6CGS 3416 Spring 2017 Loops February 6, 2017 17 / 17