资源描述:
《Java语言程序设计与数据结构 基础篇原书第11版PPT及其他教辅资源02slide.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1Chapter2ElementaryProgramming2MotivationsIntheprecedingchapter,youlearnedhowtocreate,compile,andrunaJavaprogram.Startingfromthischapter,youwilllearnhowtosolvepracticalproblemsprogrammatically.Throughtheseproblems,youwilllearnJavaprimitivedatatypesandrelatedsubje
2、cts,suchasvariables,constants,datatypes,operators,expressions,andinputandoutput.3ObjectivesTowriteJavaprogramstoperformsimplecomputations(§2.2).ToobtaininputfromtheconsoleusingtheScannerclass(§2.3).Touseidentifierstonamevariables,constants,methods,andclasses(§2.4
3、).Tousevariablestostoredata(§§2.5–2.6).Toprogramwithassignmentstatementsandassignmentexpressions(§2.6).Touseconstantstostorepermanentdata(§2.7).Tonameclasses,methods,variables,andconstantsbyfollowingtheirnamingconventions(§2.8).ToexploreJavanumericprimitivedataty
4、pes:byte,short,int,long,float,anddouble(§2.9.1).Toreadabyte,short,int,long,float,ordoublevaluefromthekeyboard(§2.9.2).Toperformoperationsusingoperators+,-,*,/,and%(§2.9.3).ToperformexponentoperationsusingMath.pow(a,b)(§2.9.4).Towriteintegerliterals,floating-point
5、literals,andliteralsinscientificnotation(§2.10).Towriteandevaluatenumericexpressions(§2.11).ToobtainthecurrentsystemtimeusingSystem.currentTimeMillis()(§2.12).Touseaugmentedassignmentoperators(§2.13).Todistinguishbetweenpostincrementandpreincrementandbetweenpostd
6、ecrementandpredecrement(§2.14).Tocastthevalueofonetypetoanothertype(§2.15).Todescribethesoftwaredevelopmentprocessandapplyittodeveloptheloanpaymentprogram(§2.16).Towriteaprogramthatconvertsalargeamountofmoneyintosmallerunits(§2.17).Toavoidcommonerrorsandpitfallsi
7、nelementaryprogramming(§2.18).4IntroducingProgrammingwithanExampleListing2.1ComputingtheAreaofaCircleThisprogramcomputestheareaofthecircle.RunComputeAreaNote:ClickingthebluebuttonrunsthecodefromWindows.Ifyoucannotrunthebuttons,seeIMPORTANTNOTE:Ifyoucannotrunthebu
8、ttons,seeliveexample.pearsoncmg.com/slide/javaslidenote.doc.Note:Clickingthegreenbuttondisplaysthesourcecodewithinteractiveanimation.Youcanalsorunthecodeinabro