免费预览已结束,剩余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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年许昌陶瓷职业学院单招职业倾向性考试题库及参考答案详解
- 2026年西安医学高等专科学校单招职业适应性测试题库附答案详解
- 2026年德宏职业学院单招职业适应性考试题库含答案详解
- 2026年长春健康职业学院单招职业适应性考试题库参考答案详解
- 2026年白银希望职业技术学院单招职业技能考试题库及参考答案详解一套
- 2026年安徽省合肥市单招职业倾向性考试题库含答案详解
- 2026年辽宁省抚顺市单招职业适应性考试题库附答案详解
- 2026年内蒙古电子信息职业技术学院单招职业适应性测试题库及参考答案详解1套
- 2026年广州城建职业学院单招职业适应性考试题库及参考答案详解
- 2026年青岛职业技术学院单招职业倾向性考试题库及参考答案详解
- 医疗器械销售渠道拓展计划书
- 2025年超星尔雅学习通《法治教育与社会法治观念》考试备考题库及答案解析
- 2025及未来5年印染布料项目投资价值分析报告
- (2025年)医学装备管理试题(带答案)
- 技术研发中心岗位等级划分细则
- 康养中心项目技术方案
- 党政面试浙江备考宝典
- AE(AfterEffects)零基础入门教程
- 幼儿园保健医考核试题及答案解析(2025版)
- 肠造口相关护理教案(2025-2026学年)
- 赞美与表扬的力量班会课件《夸夸乐大会》
评论
0/150
提交评论