- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
06发饿
? Peter Andreae, Xiaoying Gao ? Peter Andreae, Xiaoying Gao ? Peter Andreae, Xiaoying Gao String, ScannerCOMP 102 #6 2010 T2 Xiaoying Gao ( Sharon) Computer Science Victoria University of Wellington Menu Review, Assignment 2, questions The String class Input using a scanner Admin Volunteer note taker Labs are open 7/24, can use CO238, CO237 at any time Today’s lab at CO238: 11-12, 2-3 The first program /** Program for converting between temperature scales */ public class TemperatureConverter{ /** Print out the conversion formula */ public void printFormula(){ System.out.println(“Centigrade = (Fahrenheit - 32) *5/9); } /** Convert from fahrenheit to centigrade */ public void fahrenToCent(int fahren){ int cent; cent = (fahren - 32) * 5 / 9; System.out.println(fahren + F - + cent + C); } } LabRequirements with JOptionPane public class LabRequirements{ /** Ask user for code and number of students, then print number of lab streams and tutor hours required */ public void printRequirements(){ String code = JOptionPane.showInputDialog(Course: ); String ans = JOptionPane.showInputDialog(Num of students: ); int numStudents = Integer.parseInt(ans); int numStreams = numStudents / 32; int tutorHours = numStreams * 3 * 2; System.out.printf( %s needs %d streams and %d tutor hours\n, code, numStreams, tutorHours); } } printf and Format strings System.out.printf(format-string , arg1 , arg2 , …) Format string Literal String to print out, but any ‘%...’ are replaced by an argument,formatted in the specified way: eg …printf(“%s is %d years old and %4.2f cm high.\n”, name, age, ht); %s means print the string %d means print as a decimal integer %4.2f means print as a floating point number, with at least 4 characters, and exactly 2 decimal places. 3rd version, call your own method that returns a value Import javax.swing.*; public class ReactiontimeMeasure{ public void askFourQue
您可能关注的文档
- 高速公路项目部廉政建设制度.doc.doc
- 鲍集中心小学综合实践活动教研工作计划.doc
- 高考语文复习语句衔接专题——排序题答题技巧课件.ppt.ppt
- 黑龙江鸡西矿业总医院院长吴庆沿【精选资料】.doc
- 杭州铁路东站枢纽东、西广场区块配套设施项目-东广场区块绿化景观工程技术标.doc
- XX建筑工程总公司总承包部部门职能与人员编制(人力资源部)(DOC 26页).doc
- XX建筑工程总公司总承包部部门职能与人员编制(技术发展部)(DOC 22页).doc
- XX建筑工程总公司总承包部部门职能与人员编制(项目管理部)(DOC 40页).doc
- XX镇平安创建工作自查报告 .docx
- 齿轮齿条式转向器设计(含CAD图纸) .doc.doc
文档评论(0)