Presentation is loading. Please wait.

Presentation is loading. Please wait.

7/7/2016 1R. Smith - University of St Thomas - Minnesota CISC 130 - Today’s Class RecapRecap Project ProposalProject Proposal Problem 12Problem 12 Final.

Similar presentations


Presentation on theme: "7/7/2016 1R. Smith - University of St Thomas - Minnesota CISC 130 - Today’s Class RecapRecap Project ProposalProject Proposal Problem 12Problem 12 Final."— Presentation transcript:

1 7/7/2016 1R. Smith - University of St Thomas - Minnesota CISC 130 - Today’s Class RecapRecap Project ProposalProject Proposal Problem 12Problem 12 Final notes on Problem 11Final notes on Problem 11

2 Recap Problem 11Problem 11 Problem 12Problem 12 –Objectives –Scaling 7/7/2016 2R. Smith - University of St Thomas - Minnesota

3 Projects!! Proposal Due Thursday! (Tomorrow)Proposal Due Thursday! (Tomorrow) Plan due Next Wednesday!Plan due Next Wednesday! Let’s look at the Project…Let’s look at the Project… 7/7/2016 3R. Smith - University of St Thomas - Minnesota

4 7/7/2016 4R. Smith - University of St Thomas - Minnesota Assignment 12: Scaling Date Due: Next MondayDate Due: Next Monday The problem:The problem: –Taking a set of data and scaling it to fit a particular range –A common lab data problem What we’ll doWhat we’ll do –Read in a file of data to be scaled –Calculate scaled values –Print out the original data w/scaled horizontal histogram

5 7/7/2016 5R. Smith - University of St Thomas - Minnesota Assignment 12: The File Line-oriented file again, like in A11Line-oriented file again, like in A11 Name/Number instead of Number/NameName/Number instead of Number/Name Separated by tab character “\t”Separated by tab character “\t” Read “names” into one arrayRead “names” into one array Read “numbers” into a separate arrayRead “numbers” into a separate array Use a third integer array for scaled valuesUse a third integer array for scaled values

6 7/7/2016 6R. Smith - University of St Thomas - Minnesota How Scaling Works Scan the raw data in the arrayScan the raw data in the array –Find the minimum and maximum values –Minimum maps to 0 in scaled values –Maximum maps to 31 in scaled values Calculate the scaling ratioCalculate the scaling ratio –Range of desired values / range of actual values scale = 31.0 / (max – min)scale = 31.0 / (max – min) –A real number, not an int Apply the ratio and round the resultApply the ratio and round the result –Subtract ‘min’ before scaling –Use “rint()” function from math.h –Save scaled values in the scaled array

7 7/7/2016 7R. Smith - University of St Thomas - Minnesota Example Scaling Unscaled ValuesUnscaled Values2001000253600999823410 Scaled Values 0 31 2 16 31 24 8

8 7/7/2016 8R. Smith - University of St Thomas - Minnesota The Histogram Horizontal FormatHorizontal Format Left side of display: name and unscaled valueLeft side of display: name and unscaled value Right side: histogram of scaled valueRight side: histogram of scaled value

9 7/7/2016 9R. Smith - University of St Thomas - Minnesota Sample Input Moose Mountain986Moose Mountain986 Mystery Mountain650Mystery Mountain650 Eagle Mountain650Eagle Mountain650 Ullr Mountain350Ullr Mountain350 Welch Village360Welch Village360 Spirit Mountain700Spirit Mountain700 Keystone3128Keystone3128 Steamboat Springs3668Steamboat Springs3668 Sunday River2340Sunday River2340

10 Looking at the Assignment It’s almost all recycling from other programsIt’s almost all recycling from other programs One nit – you need a char->decimal conversionOne nit – you need a char->decimal conversion Let’s play with that.Let’s play with that. 7/7/2016 10R. Smith - University of St Thomas - Minnesota

11 Looking at the Assignment The assignment outlines how to recycle functions you’ve written already.The assignment outlines how to recycle functions you’ve written already. If you have questions, ask.If you have questions, ask. 7/7/2016 11R. Smith - University of St Thomas - Minnesota

12 Final Notes on Assignment 11 The comments must match your code!The comments must match your code! If you think there may be discrepancies, fix them and resubmit!If you think there may be discrepancies, fix them and resubmit! You should be able to do this without breaking your code.You should be able to do this without breaking your code. –But– be sure to test your code after you make any changes, even if you’re just changing comments. 7/7/2016 12R. Smith - University of St Thomas - Minnesota

13 7/7/2016 13R. Smith - University of St Thomas - Minnesota Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by- sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.


Download ppt "7/7/2016 1R. Smith - University of St Thomas - Minnesota CISC 130 - Today’s Class RecapRecap Project ProposalProject Proposal Problem 12Problem 12 Final."

Similar presentations


Ads by Google