58 Pages

02-basics

Course: CS 101, Fall 2008
School: UVA
Rating:
 
 
 
 
 

Word Count: 3801

Document Preview

CS101E 1 DisplayForecast.java //Authors:J.P.CohoonandJ.W.Davidson Javabasics Chapter2 //Purpose:displayaquotationinaconsolewindow publicclassDisplayForecast{ Threecomments //methodmain():applicationentrypoint publicstaticvoidmain(String[]args){ System.out.print("Ithinkthereisaworldmarketfor"); System.out.println("maybefivecomputers.");...

Register Now

Unformatted Document Excerpt

Coursehero >> Virginia >> UVA >> CS 101

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
CS101E 1 DisplayForecast.java //Authors:J.P.CohoonandJ.W.Davidson Javabasics Chapter2 //Purpose:displayaquotationinaconsolewindow publicclassDisplayForecast{ Threecomments //methodmain():applicationentrypoint publicstaticvoidmain(String[]args){ System.out.print("Ithinkthereisaworldmarketfor"); System.out.println("maybefivecomputers."); System.out.println("ThomasWatson,IBM,1943."); } } //indicatesrestofthelineisacomment Programsarereadbypeoplemakesuretheyare Aclasslikeamethodmusthaveaname Aclassdefinesanobjectform.Anobjectcanhave Javaallowsastatementtobemadeupofmultiplelines Wewilldiscussstaticandvoidlater public,static,andvoidarekeywords.Theycannotbe Anapplicationprogramisrequiredtohaveapublic Amethodisanamedpieceofcodethatperformssome Threestatementsmakeuptheactionofmethodmain() readable. methodsandattributes oftext usedasnames staticvoidmethodnamedmain(). actionorimplementsabehavior Commentsareusedtodocumentauthors,purpose,and Methodmain()ispartofclassDisplayForecast programelements Usewhitespace,comments,andindentationtoaid Semicolonsdelimitonestatementfromthenext 2 publicmeansthemethodisshareable Keywordclassindicatesaclassdefinitionfollows understanding Indentation //Authors:J.P.CohoonandJ.W.Davidson //Purpose:displayaquotationinaconsolewindow publicclassDisplayForecast{ Methodmain()ispartof DisplayForecast //methodmain():applicationentrypoint publicstaticvoidmain(String[]args){ System.out.print("Ithinkthereisaworldmarketfor"); System.out.println("maybefivecomputers."); System.out.println("ThomasWatson,IBM,1943."); } Statementsarepart } ofmethodmain() 3 Indentationindicatessubcomponents Goodwhitespacing //Authors:J.P.CohoonandJ.W.Davidson //Purpose:displayaquotationinaconsolewindow publicclassDisplayForecast{ Whitespace //methodmain():applicationentrypoint publicstaticvoidmain(String[]args){ System.out.print("Ithinkthereisaworldmarketfor"); System.out.println("maybefivecomputers."); System.out.println("ThomasWatson,IBM,1943."); } } Whitespaceseparatesprogramelements Whitespacebetweenprogramelementsisignoredby Java 4 Badwhitespacing Thesameprogramwithoutanywhitespacingorcomments: publicclassDisplayForecast2{publicstaticvoidmain (String[]args){System.out.print("Ithinkthereisa worldmarketfor");System.out.println("maybefive computers.");System.out.println("ThomasWatson,IBM, 1943.");}} 5 Anaside:IOCCC TheInternationalObfuscatedCCodeContest Onlineathttp://www.ioccc.org Chasverytersesyntax Sothecontesttriestomakeitterser! Onecommonmethodisbymodifyingthewhitespace 6 Anaside:IOCCC #define_F<00||FOO; #include<stdio.h> intF=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*F/OO/OO);}F_OO() { #defineQr=R[*p++'0'];while( #defineB;break;case ____ char*s="Qjou!s\\311^g\\311^n\\311^c\\::^qma%mO1JBHm%BQaP1J[O1HB%[Q<nbj\ _________ o)*|gps)<<*txjudi)m*|aQdbtf!::::;sfuvso<aQefgbvmu;aQ<m,,a%CQ<csfbla%bQ<aN2!Q\ ____________ \ndbtf!aP2Q;m>aP2Q<a%!D12J!JGJHJOJQJFJSJJJMHS%HD12D12N3!N4\nJUJT%UQm>aP4HC%T\ Qs\\q,,^>m,2<m>aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\ ______________ "c(1);*J=u?O?*J:*v[1]:53;X|=u<<57*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X", ",O),R(),O|=1<<i:J[*J48+(X=O=0)];L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N", R%PN4\nQ<g\\(aP3Q(^>aP2Q,2<n\\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n\ _______________ ";s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}",0}; \\(aP3Q(^*m>g\\(aP3Q(^<fmtf!m,,aHC%QN1!N1\nJ#Qqsjoug)#&e]o#aP1Q*aHb%#Qqvut)\ _______________ b(X){/*/X= b(X){/*/X= aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\ ________________ 1;F;X= 1;F;X= P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!b/d";k;charR[4][99] 1;F;}/*/ 1;F;}/*/ ________________ ;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>''&&(*q);{FILE*i=fopen(v intq,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(* ________________ [1],"r"),*o=fopen(q3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z ________________ &&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);returnsystem(q6);}*r=0 [R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i2||P(X&m?88:O&m?48:32);P( 9);}y(A){for(j=8;j;)~A&w[j]||(q=0);}e(W,Z){for(i=i*q;i<9&&q;)y(W|(1<<i++& B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);pB'C':k=0;Qk<*p'0' _______________ ~Z));}R(){for(k=J[*J48]40;k;)e(w[k],X|O);}main(u,v)char**v;{a(q=1);b(1); )(*r++=fgetc(i),k++);*r=0B'I':k=*p;if(**R==k)gotoGB'G':k=*p;G:p=s;while( _______________ c(1);*J=u?O?*J:*v[1]:53;X|=u<<57*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X *p!='$'||p[1]!=k)p++;p++B'N':R[*p'0'][0]++;}}} ______________ ,O),R(),O|=1<<i:J[*J48+(X=O=0)];L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N ;s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);} ____________ c(X){/*/X= c(X){/*/X= ________ 1;F;X= 1;F;X= ____ 1;F;}/*/ 1;F;}/*/ 7 } a(X){/*/X= a(X){/*/X= #defineX #defineXX 1;F;X= 1;F;X= #defineXXX 1;F;}/*/ 1;F;}/*/ #defineXXXX #defineXXXXX char*z[]={"char*z[]={","a(X){/*/X=","1;F;X=","1;F;}/*/","9999999999:|", #defineXXXXXX "intq,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*", #defineXXXXXXX #defineorfafor "z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z", #defineXXXXXXXXX "[R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i2||P(X&m?88:O&m?48:32);P(", #definearchachar #defineainmamain "9);}y(A){for(j=8;j;)~A&w[j]||(q=0);}e(W,Z){for(i=i*q;i<9&&q;)y(W|(1<<i++&", #defineetchargagetchar "~Z));}R(){for(k=J[*J48]40;k;)e(w[k],X|O);}main(u,v)char**v;{a(q=1);b(1);", #defineutcharpaputchar XX XXXX XXXX XXXX XXXX XXXX XXXX XXXXXX XXXXXXXX XXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX XXXXXXXXainma(){archaXXXXXXXX XXXXXXoink[9],*igpa,XXXXXX XXXXXXXatinla=etcharga(),iocccwaXXXXXXX XXXXX,apca='A',owla='a',umna=26XXXXX XXXX;orfa(;(atinla+1)&&(!(((XXXX XXXatinlaapca)*(apca+umnaatinla)XXX XX>=0)+((atinlaowla)*(owla+umnaXX Xatinla)>=0)));utcharpa(atinla),X XXatinla=etcharga());orfa(;atinla+1;XX XX){orfa(igpa=oink,iocccwa=(XX XX(atinlaXXXapca)*(XXXapca+umnaXX Xatinla)>=0)XXXXXX;((((X XatinlaapcaXXXXXXXXXXXXXXXXX)*(apca+X XumnaatinlaXXXXXX)>=0)XXXXXX+((atinlaX Xowla)*(owla+XXXXumnaXXXXatinla)>=0))X X&&"Pig"XX"Latin"XX"CObfus"X X"cation!!"[X(((atinlaXapca)*(apca+X Xumnaatinla)X>=0)?atinlaXapca+owla:X Xatinla)owlaX]'')||((igpa==Xoink)&&!(*(X Xigpa++)='w')X)||!X(*(XigpaX++)=owla);*X X(igpa++)=((X(XXXXXXXatinlaapcaX X)*(apca+XumnaXXXXXXXatinla)>=0)X X?atinlaXapcaXXX+XXXowlaX:atinla),X Xatinla=XXXXetcharga())X X;orfa(Xatinla=iocccwa?((X(atinlaX Xowla)*(owla+Xumnaatinla)>=0X)?atinlaX Xowla+apca:Xatinla):Xatinla;(((X Xatinlaapca)*X(apca+umnaXatinla)>=0)+(X X(atinlaowla)*X(owla+Xumnaatinla)>=X X0));utcharpa(XXXXatinla),atinlaX X=etcharga());XXXXXXXorfa(*igpa=0,X Xigpa=oink;*igpa;utcharpa(X X*(igpa++)));orfa(;(atinla+1)&&(!(((X Xatinlaapca)*(apca+X XumnaXXXXXXXXXXatinla)>=0X X)+((XXXXXatinlaX XXowla)*(owla+umnaXX XXatinla)>=0)));utcharpaXX XX(atinla),atinla=XX XXetcharga());}XX XXXX}XXXX XXXXXXXXX Identifiers Identifiersarenamesforvariables,classes,etc. Goodonesarecompact,butinidicatewhattheystandfor radius,width,height,length Badonesareeithertoolong theRadiusOfTheCircle theWidthOfTheBoxThatIsBeingUsed the_width_of_the_box_that_is_being_used Ortooshort a,b,c,d,e Goodidentifierswillhelpthegradersunderstandyourprogram! 8 Keywords Somewordsarereserved,andcantbeusedasidentifiers //Authors:J.P.CohoonandJ.W.Davidson //Purpose:displayaquotationinaconsolewindow publicclassDisplayForecast{ //methodmain():applicationentrypoint publicstaticvoidmain(String[]args){ System.out.print("Ithinkthereisaworldmarketfor"); System.out.println("maybefivecomputers."); System.out.println("ThomasWatson,IBM,1943."); } } 9 Capitalization Casematters! publicPublicPUBLIC ThisisdifferentthatFORTRANandBASIC ThisisthesameasC/C++ YoucanusePublicasaidentifier Notrecommended,though! 10 Definingamethod Allmethodshavethefollowingsyntax: modiferstypename(parameters){statements} Properties ofthe method Type thatit returns Aname forthe method Anynumber (includingzero) ofparameters Thebodyof themethod (canbeempty) publicstatic void main (String[]args) {...} 11 Escapesequences Javaprovidesescapesequencesforprintingspecialcharacters \b backspace \n newline \t tab \r carriagereturn \\ backslash \" doublequote \' singlequote 12 Escapesequences Whatdothesestatementsoutput? System.out.println("Person\tHeight\tShoesize"); System.out.println("========================="); System.out.println("Hannah\t51\"\t7"); System.out.println("Jenna\t5'10\"\t9"); System.out.println("JJ\t6'1\"\t14"); Output PersonHeightShoesize ========================= Hannah51"7 Jenna5'10"9 JJ6'1"14 13 Primitivevariableassignment Assignmentoperator= Allowsthememorylocationforavariabletobeupdated target=expression; Name of previously defined object Expression t o be evaluat ed Consider intj=11; j=1985; j 1985 11 14 Primitivevariableassignment Consider inta=1; intaSquared=a*a; a=5; aSquared=a*a; Consider inti=0; i=i+1; Consider intasaRating; asaRating=400; a aSquared 1 5 25 1 i 1 0 asaRating 400 15 Primitivevariableassignment Consider doublex=5.12; doubley=19.28; doublerememberX=x; x=y; y=rememberX; x y rememberX 5.12 19.28 19.28 5.12 5.12 16 Primitivevariabletypes Javahas8(orso)primitivetypes: float realnumbers double twovalues:trueandfalsea boolean char asinglecharacter byte short integernumbers int long Alsothevoidtype 17 Primitivereal(floatingpoint)types Afloattakesup4bytesofspace Has6decimalplacesofaccuracy:3.14159 Adoubletakesup8bytesofspace Has15decimalplacesofaccuracy:3.14159265358979 Alwaysusedoubles Itwillsaveyouquiteaheadache! 18 Primitiveintegertypes Considerabyte: 0 1 0 0 0 1 0 1 1byte=8bits Eachbithastwopossibilities:0or1 28=256 Thus,abytecanhaveanyoneof256values AJavabytecanhavevaluesfrom128to127 From27to271 C/C++hasunsignedversions;Javadoesnot 19 Primitiveintegertypes Type byte short Bytes 1 2 Minimumvalue 27=128 215= 32,768 231=2,147,483,648 Maximumvalue 271=127 2151= 32,767 2311=2,147,483,647 int 4 long 8 263=9,223,372,036, 854,775,808 2631=9,223,372,036, 854,775,807 20 Incrementanddecrementoperators ++ Incrementsanumbervariableby1 Decrementsanumericvariableby1 i 7 6 5 4 Consider inti=4; inti=4;//define ++i;//increment ++i; System.out.println(i);//display System.out.println(i); System.out.print(++i); System.out.print(++i);//updatethendisplay System.out.print(++i); System.out.println(i++);//displaythenupdate System.out.println(i++); System.out.println(i++); System.out.println(i); System.out.println(i);//display System.out.println(i); 21 Whyyoushouldgettheextended warranty 22 Primitivecharactertype Allcharactershaveaintegerequivalent 0=48 1=49 A=65 a=97 Thus,youcanrefertoBasA+1 23 Primitivecharactertype publicclassLowerToUpper{ //main():applicationentrypoint publicstaticvoidmain(String[]args){ //setlowercasecharacterofinterest //converttouppercaseequivalent charlowerCaseLetter='c'; charupperCaseLetter='A'+(lowerCaseLetter'a'); //displayresult System.out.println("Uppercaseequivalentof"); System.out.println(""+lowerCaseLetter); System.out.println("is"); System.out.println(""+upperCaseLetter); } } 24 Primitivebooleantype WhenisthefollowingprogramvalidinJava? Assumeaandbhavebeenproperlydeclared ... if ( a && b ) { // do something interesting } ... Answer:ONLYwhenaandbarebooleanvariables InC/C++,aandbwouldbeints(orintvariants) IfyoutrymakingaandbintsinJava,yougetthefollowing: operator&&cannotbeappliedtoint,int 25 Primitivevoidtype InJava,youcanONLYusevoidtospecifythatamethoddoesnot returnavalue Youcannotuseittodeclareavoidvariable,asinC/C++: void *foo; Youcannotuseittospecifythattherearenoparameterstoamethod: ... int foo (void) { ... ThisisdifferentfromC/C++ 26 Variableinitialization Considerthefollowingcode: intx; System.out.println(x); Whathappens? Errormessage: variablexmightnothavebeeninitialized 27 Constants Considerthefollowing: finalintx=5; ThevalueofxcanNEVERbechanged! Thevalueassignedtoitisfinal ThisishowJavadefinesconstants 28 Expressions Whatisthevalueusedtoinitializeexpression intexpression=4+2*5; Whatvalueisdisplayed System.out.println(5/2.0); Javarulesinanutshell Eachoperatorhasaprecedencelevelandanassociativity Operatorswithhigherprecedencearedonefirst *and/havehigherprecedencethan+and 29 Associativityindicateshowtohandleties Whenfloatingpointisusedtheresultisfloatingpoint Questiononexpressions Doesthefollowingstatementcomputetheaverageofdoublevariables a,b,andc?Why doubleaverage=a+b+c/3.0; 30 System.out.println() publicstaticvoidmain(String[]args){ System.out.print("Ithinkthereisaworldmarketfor"); System.out.println("maybefivecomputers."); System.out.println("ThomasWatson,IBM,1943."); } ClassSystemsuppliesobjectsthatcanprintandreadvalues Systemvariableoutreferencesthestandardprintingobject Knownasthestandardoutputstream Variableoutprovidesaccesstoprintingmethods print():displaysavalue println():displaysavalueandmovescursortothenextline 31 System.out System.out:PrintStream destination= ... Variable System.out gives access to an output stream of type PrintStream println(Strings):void print(Strings):void +... The printing destination attribute for this PrintStream object is the console window The behaviors of a PrintStream object support a high-level view printing 32 Selection The period indicates that we want to The period indicates that we want to select select an individual class member of out an individual class member of System The method we are calling . System . outprint( s ) " tring " Member out of System is an output Literal character string that is stream object automatically associated with the console window the parameter to print(). running the application Class System is defined in the standard Method member of out. The execution of member print() package java.lang causes its parameter to be displayed to the output stream 33 I/Ostreams System.out Printstostandardoutput EquivalenttocoutinC++,andprint()inC System.err Printstostandarderror EquivalenttocerrinC++,andfprintf(stderr)inC System.in Readsfromstandardinput EquivalenttocininC++,andscanf()inC 34 Beware!!! 35 Exampleprogram:temperature conversion //Purpose:ConvertaCelsiustemperaturetoFahrenheit publicclassCelsiusToFahrenheit{ //main():applicationentrypoint publicstaticvoidmain(String[]args){ //setCelsiustemperatureofinterest intcelsius=28; //converttoFahrenheitequivalent intfahrenheit=32+((9*celsius)/5); //displayresult System.out.println("Celsiustemperature"); System.out.println(""+celsius); System.out.println("equalsFahrenheittemperature"); System.out.println(""+fahrenheit); } } 36 Computation Programmersfrequentlywritesmallprogramsforcomputinguseful things Examplebodymassindex(BMI) Measureoffitness Ratioofpersonsweighttothesquareofthepersonsheight Weightiniskilograms,heightisinmeters Personofinterestis4.5feetandweighs75.5pounds Metricconversions Kilogramsperpound0.454 Metersperfoot0.3046 37 ProgramoutlineforBMI.java //Purpose:ComputeBMIforgivenweightandheight publicclassBMI{ //main():applicationentrypoint publicstaticvoidmain(String[]args){ //defineconstants //setupperson'scharacteristics //converttometricequivalents //performbmicalculation //displayresult } } 38 BMI.java:defineconstants KILOGRAMS_PER_POUND 0.454 //defineconstants finaldoubleKILOGRAMS_PER_POUND=0.454; finaldoubleMETERS_PER_FOOT=0.3046; METERS_PER_FOOT 0.3046 39 BMI.java:personalcharacteristics weightInPounds 75.5 //setupperson'scharacteristics doubleweightInPounds=75.5;//ourpersonsweight doubleheightInFeet=4.5;//ourpersonsheight heightInFeet 4.5 40 BMI.java:converttometricequivalents metricWeight 34.2770 //converttometricequivalents doublemetricWeight=weightInPounds* KILOGRAMS_PER_POUND; doublemetricHeight=heightInFeet* METERS_PER_FOOT; metricHeight 1.3706 41 BMI.java:performBMIcalculation //performbmicalculation doublebmi=metricWeight/(metricHeight* metricHeight); bmi 18.2439 42 BMI.java:displayresult bmi 18.2439 //displayresult System.out.println("Apersonwith"); System.out.println("weight"+weightInPounds+"lbs"); System.out.println("height"+heightInFeet+"feet"); System.out.println("hasaBMIof"+Math.round(bmi)); Math.round(bmi)is18 Operatorevaluationdependuponitsoperands 43 publicstaticvoidmain(String[]args){ //defineconstants finaldoubleKILOGRAMS_PER_POUND=0.454; finaldoubleMETERS_PER_FOOT=0.3046; //setupperson'scharacteristics doubleweightInPounds=75.5;//ourpersonsweight doubleheightInFeet=4.5;//ourpersonsheight //converttometricequivalents doublemetricWeight=weightInPounds* KILOGRAMS_PER_POUND; doublemetricHeight=heightInFeet*METERS_PER_FOOT; //performbmicalculation doublebmi=metricWeight/(metricHeight*metricHeight); //displayresult System.out.println("Apersonwith"); System.out.println("weight"+weightInPounds+"lbs"); System.out.println("height"+heightInFeet+"feet"); System.out.println("hasaBMIof"+Math.round(bmi)); } Pentiummatherror1 IntelsPentiums (60Mhz100Mhz) hadafloatingpoint error Graphofz=y/x Intelreluctantly agreedtoreplace themin1994 Graphfromhttp://kuhttp.cc.ukans.edu/cwis/units/IPPBR/pentium_fdiv/pentgrph.html 45 Pentiummatherror2 Top10reasonstobuyaPentium: YouroldPCistooaccurate ProvidesagoodalibiwhentheIRScalls AttractedbyIntel'snew"Youdon'tneedtoknowwhat's inside"campaign Itredefinescomputingandmathematics! You'vealwayswonderedwhatitwouldbeliketobea plaintiff Currentpaperweightnotbigenough Takesconceptof"floatingpoint"toanewlevel Youalwaysroundofftothenearesthundredanyway GotagreatdealfromtheJetPropulsionLaboratory It'llprobablywork!! 46 10 8.9999163362 7.9999414610 6.999...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UVA - CS - 101
Even even more on being classyAaron Bloomfield CS 101-E Chapter 4+1Consider this sequence of events.2What happened? Javadidn't &quot;repaint&quot; the rectangles when necessary Javaonly painted the rectangle once Youcan tell Java to repaint i
UVA - CS - 101
ReviewofHWJ3AaronBloomfield CS101EStrandrepresentationStrand nucleotideSequence= String text=tgccagt tgccagt length=7publicStrandslice(inti1,inti2) publicStrand() publicStrand() +length():int publicStrand(Strings) publicStrand(Strings) +charAt
UVA - CS - 101
Visibilities and Static-nessAaron Bloomfield CS 101-EOur Circle classWe are going to write a Circle class Somebody else is going to use it public class Circle { double radius; double Pi = 3.1415926536; }Note the fields are not static Note the ra
UVA - CS - 101
221nosotros weesperamos hopeque that/whatpuede canuna aoracin sentenceleo logleno logzorro foxrpido quickmarrn brownsalt jumpedsalto jumpedsobre overregistro data-logperezoso lazyo orsusyourprofesores professorsestudiantestudent
UVA - CS - 101
A B CD E FThis file has 42 characters.
UVA - CS - 101
/ Authors: J. P. Cohoon and J. W. Davidson/ Purpose: display a quotation in a console windowpublic class DisplayForecast {/ method main(): application entry pointpublic static void main(String[] args) {System.out.print(&quot;I think ther
UVA - CS - 101
CS 101 / CS 101-EFall 2005 http:/www.cs.virginia.edu/~cs101M/W 2:00-3:15 CHM 402 / OLS 009Instructors: CS 101 Aaron Bloomfield http:/www.cs.virginia.edu/~asbCS 101-E David Luebke http:/www.cs.virginia.edu/~luebkeOffice: Olsson Hall, room 228D
UVA - CS - 101
CS 101 / CS 101-EFall 2006 http:/www.cs.virginia.edu/~cs101 CS 101: M/W 2:00-3:15 in CHM 402 CS 101-E: M/W 3:30-4:45 in MEC 341Instructors: CS 101 Aaron Bloomfield http:/www.cs.virginia.edu/~asb Office: Olsson Hall, room 228D Office hours are poste
UVA - CS - 202
CS 202, Discrete Math Spring 2007Mondays and Wednesdays 1:00-1:50 Recitation on Fridays at 11:00 or 1:00Instructor: Aaron Bloomfield. Office: Olsson Hall, room 228D ( Course web page: http:/www.cs.virginia.edu/~cs202/ Introduction: This class will
UVA - CS - 494
CS 494 Homework 3: Due 27 March 2006In this homework, you will complete the second elaboration iteration for the project you described in the first homework. In particular, you will have another functioning version of your system ready by the end o
UVA - CS - 202
CS/APMA 202, Spring 2005Tu/Th 3:30-4:45 Olsson Hall room 120Instructor: Aaron Bloomfield. Office: Olsson Hall, room 228D ( Course web page: http:/www.cs.virginia.edu/~asb/cs202/ Introduction: This class will probably be different than any other mat
UVA - CS - 445
CS 445: Computer GraphicsFall 2006 http:/www.cs.virginia.edu/~cs445 Instructor Aaron Bloomfield http:/www.cs.virginia.edu/~asb Office: Olsson Hall, room 228D Office hours are posted on the website Teaching Assistant Jason Mars http:/www.cs.virginia.
UVA - CS - 415
Wed 02 Nov 2005 02:01:06 AM ESTmodpow.htmlPage 1&lt;!DOCTYPE html PUBLIC &quot;-/W3C/DTD XHTML 1.0 Transitional/EN&quot; &quot;http:/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;html xmlns=&quot;http:/www.w3.org/1999/xhtml&quot; lang=&quot;en-US&quot; xml:lang= &quot;en-US&quot;&gt; &lt;hea
UVA - CS - 415
CS 415: Programming Languages Homework 2: Ocaml Due Friday, 23 September by 10 a.m.For this homework, you will need to write three Ocaml functions that deal with DFAs and NFAs: dfasimulate: given a DFA and input, will return the state transition of
UVA - CS - 415
CS 415: Programming Languages Homework 1: Fortran Due Friday, 9 September by 10 a.m.For this homework, you will need to write a Fortran program that will compute whether a circle and a triangle intersect. The program will get (as user input) the loc
UVA - CS - 494
CS 494 Homework 5: Due 2 May 2006In this homework, you will complete the fourth (and last!) elaboration iteration for the project you described in the first homework. In particular, you will have the completed version of your project ready by the e
UVA - CS - 494
CS 494 Homework 1: Due 13 Feb 2006For this homework, you will generate a proposal for a project that you will be working on throughout the semester. Essentially, you will be going through the inception phase for your project. You can work in groups
UVA - CS - 494
CS 494: Object Oriented DesignSpring 2006 http:/www.cs.virginia.edu/~cs494M/W/F 12:00-12:50 MEC 339Instructor: Aaron Bloomfield http:/www.cs.virginia.edu/~asb Office: Olsson Hall, room 228D Office hours are posted on the website Other course pers
UVA - CS - 101
CS 101 Fall 2005 Final ExamName: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Unlike midterm exams, you have a full 3 hours to work on this exam. This final exam is optional; you may choose
UVA - CS - 494
CS 494 Homework 2: Due 27 Feb 2006In this homework, you will complete the first elaboration iteration for the project you described in the first homework. In particular, you will have a fully functioning prototype version of your system ready by th
UVA - CS - 202
CS/APMA 202Midterm 27 April 2005Name: _E-mail ID: _@virginia.eduPledge: _ __ _ Signature: _There are 75 minutes for this exam and 100 points on the test; don't spend too long on any one question! The 12 short answer questions require only
UVA - CS - 101
CS 101 Fall 2005 Midterm 1Name: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts (in particular, the final question is worth substantially more than any oth
UVA - CS - 101
CS101 Fall 2005 Midterm 2 Grading GuidelinesQuestion 3: 4 points, each answer worth 1 point Question 4: 3 points, there should be 3 numbers output, each worth a point. Question 5: 3 points, one for each value (j,k, flag) Question 6: 5 points a. 3 va
UVA - CS - 101
CS 101 Spring 2006 Midterm 2Name: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure to look over all the questions and plan your time accordingly
UVA - CS - 101
Pledged CS 101 Exam 3 Spring 2005Email Id _ Name _This pledged exam is open text book and closed notes. Different questions have different points associated with them. Because your goal is to maximize your number of points, we recommend that you
UVA - CS - 101
CS 101 Final Exam Fall 2005Email Id _Name _This pledged exam is open text book and closed notes. Different questions have different points associated with them. Because your goal is to maximize your number of points, we recommend that you do not
UVA - CS - 415
CS 415 Midterm Exam Spring 2002Name _KEY _ Email Address _ Student ID # _Pledge:This exam is closed note, closed book. Good Luck!Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming Total/100CS415Anderson Sp
UVA - CS - 415
INTERCALAaron Bloomfield CS 415 Fall 2005A note about the sourcesThe main sources for this lecture set are:The INTERCAL page in Wikipediahttp:/en.wikipedia.org/wiki/IntercalThe INTERCAL Programming Language Revised Reference Manual
UVA - CS - 445
TransformationsAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)Graphics coordinate systems X is red Y is green Z is blue2Graphics coordinate systemsIf you are on the +z axis, and +y is
UVA - CS - 415
Names, Scopes and BindingsAaron Bloomfield CS 415 Fall 200511Binding A binding is an association between two things, such as a name and the thing it represents Example: int x When this statement is compiled, x is bound to a memory space2B
UVA - CS - 415
Debuggers, Analysis Tools and ProfilersAaron Bloomfield CS 415 Fall 20051What is a Debugger?&quot;A software tool that is used to detect the source of program or script errors, by performing step-by-step execution of application code and viewing the
UVA - CS - 445
Rendering PipelineAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)3D Polygon RenderingMany applications use rendering of 3D polygons with direct illumination23D Polygon RenderingMany ap
UVA - CS - 445
LightingAaron Bloomfield CS 445: Introduction to Graphics Fall 2006Lighting Sogiven a 3-D triangle and a 3-D viewpoint, we can set the right pixels But what color should those pixels be? If were attempting to create a realistic image, we need
UVA - CS - 415
ScanningAaron Bloomfield CS 415 Fall 20051Parsing &amp; Scanning In real compilers the recognizer is split into two phases Scanner: translate input characters to tokens Also, report lexical errors like illegal characters and illegal symbols Pars
UVA - CS - 445
Rendering Pipeline and Graphics HardwareAaron Bloomfield CS 445: Introduction to Graphics Fall 2006Overview Framebuffers How is the rasterized Rendering Pipeline scene kept in memory? Transformations Lighting Clipping Modeling Camera Vis
UVA - CS - 202
Set OperationsCS/APMA 202, Spring 2005 Rosen, section 1.7 Aaron Bloomfield1Sets of ColorsMonitor gamut (M) Printer gamut (P) Pick any 3 &quot;primary&quot; colors Triangle shows mixable color range (gamut) the set of colors2Set operations: Union 1
UVA - CS - 415
In More Depth.Grammars Parsing(Slides copied liberally from Ruth Anderson, Hal Perkins and others)04/19/09CS415 - Fall 20051Parsing The syntax of most programming languages can be specified by a context-free grammar (CGF) Parsing: Given a
UVA - CS - 202
Nested QuantifiersCS/APMA 202, Spring 2005 Rosen, section 1.4 Aaron Bloomfield1Multiple quantifiersYou can have multiple quantifiers on a statement x y P(x, y) &quot;For all x, there exists a y such that P(x,y)&quot; Example: x y (x+y = 0) xy P(x,y)
UVA - CS - 445
CS 445 Introduction to Computer GraphicsFall 2006 Aaron BloomfieldOverviewIntroductionWhat is computer graphics? What is it good for? What will I learn in this course? How much work will there be?ApplicationsSyllabusCoursework
UVA - CS - 415
CS 415: Programming LanguagesAlgol Aaron Bloomfield Fall 2005Historical perspectiveBy mid/late 50s a lot of PLs were out there Interest in universal language European and American groups got together in Zurich Result was Algol 58 8 people spe
UVA - CS - 445
General-Purpose Computation on Graphics HardwareDavid LuebkeUniversity of VirginiaCourse Introduction The GPU on commodity video cards has evolved into an extremely flexible and powerful processor Programmability Precision Power We are in
UVA - CS - 445
RasterizationAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)The Rendering Pipeline: A TourTransform Illuminate Transform Clip Project RasterizeMode &amp; C e l am ra Param te e rsRe ring Pipe nde
UVA - CS - 202
FunctionsCS 202 Epp section ? Aaron Bloomfield1Definition of a function A function takes an element from a set and maps it to a UNIQUE element in another set2Function terminologyf maps R to Z Domain R f Z Co-domainf(4.3) 4.3 4Pre-image
UVA - CS - 202
Propositional EquivalencesCS/APMA 202, Spring 2005 Rosen, section 1.2 Aaron Bloomfield1Tautology and ContradictionA tautology is a statement that is always truep p will always be true(Negation Law)A contradiction is a statement that is al
UVA - CS - 415
Objective Caml (Ocaml)Aaron Bloomfield CS 415 Fall 20051ML history ML first developed in late 1970's Stands for Meta Langauage Not a &quot;pure&quot; function language Has functions with side effects, imperative programming capabilities Haskell is a
UVA - CS - 202
Methods of ProofCS 202 Rosen section 1.5 Aaron Bloomfield1In this slide set.Rules of inference for propositions Rules of inference for quantified statements Ten methods of proof2Proof methods in this slide setLogical equivalences Ten pro
UVA - CS - 202
Boolean LogicCS 202, Spring 2007 Epp, sections 1.1 and 1.2 Aaron Bloomfield1Administratrivia HW 1: due next Friday Section 1.1 # 49, 52 Section 1.2 # 34, 44, 46 Today's lecture will be somewhat of a review Next week we will see applications
UVA - CS - 445
Making MoviesAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Brogan)Making Movies Concept Storyboarding Sound Character Development Layout and look Effects Animation Lighting2Concept&quot;Not
UVA - CS - 101
GUI programmingGraphical user interfacebased programmingWindchill Windchill There are several formulas for calculating the windchill temperature twc The one provided by U.S. National Weather Service and is applicable for a windspeed greater tha
UVA - CS - 101
Fall 2004 - CS 101: Test 1Name _UVA Email ID _I. Computing and programming fundamentals1. (4 points) Give two examples of non-PC computing devices.Part I Part II Part III2. (4 points) What does Java program compilation do?Total3. (4 poin
UVA - CS - 101
Fall 2004 - CS 101: Test 3Name _UVA Email ID _Page 1 _ / 10 1. (Bonus 2 points) What is your section? 101 Page 4 _ / 17 101E Page 5 _ / 25 Page 6 _ / 20 Page 2 _ / 10 Page 3 _ / 18Total _ /100 2. (5 points) What is the output of the following c
UVA - CS - 101
CS 101 Exam 1 Spring 200Email Id _ Name _This exam is open text book and closed notes. Different questions have different points associated with them with later occurring questions having more worth than the beginning questions. Because your goal
UVA - CS - 101
CS 101 / CS 101-Ehttp:/www.cs.virginia.edu/~cs101M/W 2:00-3:15 CHM 402 / MEC 205Instructors: CS 101 Aaron Bloomfield http:/www.cs.virginia.edu/~asbCS 101-E James Cohoon http:/www.cs.virginia.edu/~cohoonOffice: Olsson Hall, room 228D Office: O
UVA - CS - 101
Take care with floating-point valuesConsider double a = 1; double b = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 double c = .9999999999999999; Two true expressions! c = b b != a Two false expressions! a = b b != c Problem lies with th
UVA - CS - 101
Testing and ExceptionsException Abnormal event occurring during program execution Examples Manipulate nonexistent files File file = new File(s); Scanner fileIn = new Scanner(file); Improper array subscripting int[] a = new int[3]; a
UVA - CS - 101
BooleanvaluesGatewaytodecisionmakingBackground Ourproblemsolvingsolutionssofarhavethestraightlineproperty TheyexecutethesamestatementsforeveryrunoftheprogrampublicclassDisplayForecast /main():applicationentrypoint publicstaticvoidmain(String[]a
UVA - CS - 101
Cir cleKeeps on r ol l i ng Pr oblem design a cir cle r epr esent at ionSome possi bl e questi ons to ask What ki nd of ci r cl e? Why not use an exi sti ng ci r cl e r epr esentati on? What pl ans do you have for the ci r cl e? What
UVA - CS - 101
ClassesPreparation Scenesofarhasbeenbackgroundmaterialandexperience Computingsystemsandproblemsolving Variables Types Inputandoutput Expressions Assignments Objects StandardclassesandmethodsReady ExperiencewhatJavaisreallyabout Designa
UVA - CS - 101
Review for exam 1CS 101 Aaron Bloomfield1Todays lectureAn overview of the review sections of chapters 1-3 Stop me if you want me to go over something in more detail!2Material you may not be comfortable withConstructorsI know there is a
UVA - CS - 101
Iteration 1Java loopingOptions while dowhile for Allow programs to control how many times a statement list is executed 2AveragingProblem Extract a list of positive numbers from standard input and produce their average Number
UVA - CS - 101
Programming with methods and classes 1MethodsInstance (or member) method Operates on a object (i.e., and instance of the class)String s = new String(&quot;Help every cow reach its &quot; + &quot;potential!&quot;); int n = s.length(); Instance method