CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich [email protected] 1 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 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 Program 1 • Style Descriptive name Indentation Line too long • Unused code Not style 4 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 5 Find Max, Min, Average of m Sections Max, Min and Average of each section Max, Min and Average of all sections together Note10 6 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 7 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 8 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 9 Prog2 Winner // No winner for now else if (totalDistance =< minTotalDistance || numDeiveries >= maxDeiveries) { winnerNum = -1; if (totalDistance < minTotalDistance) minTotalDistance = totalDistance; if (numDeiveries > maxDeiveries) maxDeiveries = numDeiveries; } 10 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; } } 11 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 } 12 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) 13 Why is CS1430 Very Difficult? • Understand concepts • Make programs work • Follow rules 14 Good Luck! • Come to classes/labs • Do the work by yourself • Get Help • Review Notes • Follow Instructions • Pay attention to details 15 Go to Lab 206 • Quiz4-1 • Prog2 • Test 1 16
© Copyright 2026 Paperzz