Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich

Similar presentations


Presentation on theme: "1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich"— Presentation transcript:

1 1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich YangQ@uwplatt.edu

2 Test1 Ask me if you have any questions If you did not well –Redo it and show me –Especially if your score is below 40 2

3 Quiz4-1 How to compute Gross Pay? Rate : 10 Hours: 40 Gross: 40 * 10 Rate : 10 Hours: 52 Gross: 40 * 10 + 12 * (1.5 * 10) Due 5 pm Today! 3

4 4 Program 1 Style Descriptive name Indentation Line too long Unused code Not style

5 5 Program 2 Due Tuesday, October 6 Individual Assignment OK to get LIMITED help from others DO NOT work as a group DO NOT copy from others DO NOT let others copy your code Program Plagiarism

6 6 Find Max, Min, Average of m Sections Max, Min and Average of each section Max, Min and Average of all sections together Note10

7 7 Computing Total Distance startX = 0 and startY = 0 While not end of route Read endX and endY Compute the distance between start and end add to the total distance Set startX and startY to endX and endY Update count

8 8 Determining the Winner If first route Set winnerNum Set minTotalDistance and maxDeiveries Else Three possibilities The new route is the winner No winner The previous winner still winner

9 9 Three possibilities // The new route is the winner if (totalDistance < minTotalDistance && numDeiveries > maxDeiveries) // update winnerNum, // minTotalDistance and maxDeiveries // No winner else if (totalDistance =< minTotalDistance || numDeiveries >= maxDeiveries) // update winnerNum to -1 // minTotalDistance and maxDeiveries // The previous winner still winner else // do nothing

10 10 Prog2 Winner // No winner for now else if (totalDistance =< minTotalDistance || numDeiveries >= maxDeiveries) { winnerNum = -1; if (totalDistance < minTotalDistance) minTotalDistance = totalDistance; if (numDeiveries > maxDeiveries) maxDeiveries = numDeiveries; }

11 11 Prog2 Winner: Another Way if (totalDistance < minTotalDistance && numDeiveries > maxDeiveries)... else { if (totalDistance =< minTotalDistance) { winnerNum = -1; minTotalDistance = totalDistance; } // No else ! if (numDeiveries >= maxDeiveries) { winnerNum = -1; maxDeiveries = numDeiveries; } }

12 12 Prog2 Winner: Another Way if (routeNum == 1) { distWinnerNum = routeNum; delWinnerNum = routeNum; minTotalDistance = totalDistance; maxDeiveries = numDeiveries; } else { if (totalDistance < minTotalDistance) { distWinnerNum = routeNum; minTotalDistance = totalDistance; } else if (totalDistance == minTotalDistance) { distWinnerNum = routeNum; } // else prev distWinnerNum still winner // same if – else if for delWinnerNum }

13 13 CS1430: No Prerequisite Any one can take CS143 Not any one can pass CS143 D/F rate: 25-40% Recommendation: –Previous programming experience such as CS 1130 –(Math) –(English)

14 14 Why is CS1430 Very Difficult? Understand concepts Make programs work Follow rules

15 15 Good Luck! Come to classes/labs Do the work by yourself Get Help Review Notes Follow Instructions Pay attention to details

16 16 Go to Lab 206 Quiz4-1 Prog2 Test 1


Download ppt "1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich"

Similar presentations


Ads by Google