150 likes | 357 Views
Test1. Ask me if you have any questions Redo it and show me if your score is below 40. 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!. Program 1. Style Descriptive name
E N D
Test1 • Ask me if you have any questions • Redo it and show me if your score is below 40
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!
Program 1 • Style Descriptive name Indentation Line too long • Unused code Not style
Program 2 • Due Wednesday, March 2 • 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
Find Max, Min, Average of m Sections Max, Min and Average of each section Max, Min and Average of all sections together Note09 Prog2: multiple routes multiple deliveries for each route
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
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
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
Prog2 Winner // No winner for now else if (totalDistance =< minTotalDistance || numDeiveries >= maxDeiveries) { winnerNum = -1; if (totalDistance < minTotalDistance) minTotalDistance = totalDistance; if (numDeiveries > maxDeiveries) maxDeiveries = numDeiveries; }
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; } }
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 }
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)
Why is CS1430 Very Difficult? • Understand concepts • Make programs work • Follow rules
Good Luck! • Come to classes/labs • Do the work by yourself • Get Help • Review Notes • Follow Instructions • Pay attention to details
Go to Lab 206 • Quiz4-1 • Prog2 • Test 1