




免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1.public class Exercise1_2 public static void main(String args) System.out.println(Welcome to Java); System.out.println(Welcome to Java); System.out.println(Welcome to Java); System.out.println(Welcome to Java); System.out.println(Welcome to Java); 2.public class Exercise1_4 public static void main(String args) System.out.println(a a2 a3); System.out.println(1 1 1); System.out.println(2 4 8); System.out.println(3 9 27); System.out.println(4 16 64); 3.public class Exercise1_4 public static void main(String args) System.out.println(a a2 a3); System.out.println(1 1 1); System.out.println(2 4 8); System.out.println(3 9 27); System.out.println(4 16 64); 4.public class Exercise1_6 public static void main(String args) System.out.println(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9); 5.public class Exercise1_8 public static void main(String args) / Display area System.out.println(5.5 * 5.5 * 3.14159); / Display perimeter System.out.println(2 * 5.5 * 3.14159); 6.import javax.swing.JOptionPane;public class Exercise2_1WithDialogBox / Main method public static void main(String args) / Enter a temperatur in Fahrenheit String celsiusString = JOptionPane.showInputDialog(null, Enter a temperature in Celsius:, Exercise2_1 Input, JOptionPane.QUESTION_MESSAGE); / Convert string to double double celsius = Double.parseDouble(celsiusString); / Convert it to Celsius double fahrenheit = (9.0 / 5) * celsius + 32; / Display the result JOptionPane.showMessageDialog(null, The temperature is + fahrenheit + in Fahrenheit); 7.import java.util.Scanner;public class Exercise2_2 public static void main(String args) Scanner input = new Scanner(System.in); / Enter radius of the cylinder System.out.print(Enter radius of the cylinder: ); double radius = input.nextDouble(); / Enter length of the cylinder System.out.print(Enter length of the cylinder: ); double length = input.nextDouble(); double volume = radius * radius * 3.14159 * length; System.out.println(The volume of the cylinder is + volume); 8.public class Exercise2_4 public static void main(String args) / Prompt the input java.util.Scanner input = new java.util.Scanner(System.in); System.out.print(Enter a number in pounds: ); double pounds = input.nextDouble(); double kilograms = pounds * 0.454; System.out.println(pounds + pounds is + kilograms + kilograms); 9./ Exercise2_6.java: Summarize all digits in an integer 1000public class Exercise2_6 / Main method public static void main(String args) java.util.Scanner input = new java.util.Scanner(System.in); / Read a number System.out.print(Enter an integer between 0 and 1000: ); int number = input.nextInt(); / Find all digits in number int lastDigit = number % 10; int remainingNumber = number / 10; int secondLastDigit = remainingNumber % 10; remainingNumber = remainingNumber / 10; int thirdLastDigit = remainingNumber % 10; / Obtain the sum of all digits int sum = lastDigit + secondLastDigit + thirdLastDigit; / Display results System.out.println(The sum of all digits in + number + is + sum); 10 public class Exercise2_8 public static void main(String args) java.util.Scanner input = new java.util.Scanner(System.in); / Enter an ASCII code System.out.print(Enter an ASCII code: ); int code = input.nextInt(); / Display result System.out.println(The character for ASCII code + code + is + (char)code); public class Exercise2_8 public static void main(String args) java.util.Scanner input = new java.util.Scanner(System.in); / E
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农业信息化技术与服务平台建设协议
- 农民培训及技术支持服务协议
- 【正版授权】 ISO 22514-7:2021/Amd 1:2024 EN Statistical methods in process management - Capability and performance - Part 7: Capability of measurement processes - Amendment 1
- 【正版授权】 ISO 14912:2025 EN Gas analysis - Conversion of gas mixture composition data
- 【正版授权】 IEC TR 63222-101:2025 EN Power quality management - Part 101: Power quality data application
- 【正版授权】 IEC 61058-2-4:1995+AMD1:2003 CSV EN-D Switches for appliances - Part 2-4: Particular requirements for independently mounted switches
- 福建省莆田九中2026届化学高三上期中复习检测试题含解析
- 校园足球赛安全知识培训课件
- 贵州邮政面试题及答案
- 小儿脑瘫考试题及答案
- 特殊人群服务管理制度
- 2025-2030中国磁悬浮离心鼓风机行业市场发展趋势与前景展望战略研究报告
- 高等教育自学考试《00018计算机应用基础》模拟试卷一
- 2025年公共卫生检验士考试试题及答案
- 危化品泄漏的应急处置流程
- 2025-2030中国机场酒店行业市场前瞻与未来投资战略分析研究报告
- 医保基金监管与支付资格管理专题培训
- 员工关系管理培训课件
- 2023秸秆类生物质能源原料储存规范第1部分:存放
- 餐厅收货流程
- 政府招商投资合作框架协议书模板6篇
评论
0/150
提交评论