2013年1月27日
摘要: 1 package chapter5方法; 2 //求最大公约数; 3 public class GreatestCommonDivisor { 4 public static void main(String[] args){ 5 java.util.Scanner input = new java.util.Scanner(System.in); 6 7 System.out.print("Enter first integer: "); 8 int n1 = input.nextInt(); 9 ... 阅读全文
posted @ 2013-01-27 19:46 bailun 阅读(1339) 评论(0) 推荐(0) 编辑
摘要: 4.1在A处count<100总是true;在C处count<100总是false;在B处count<100有时是true有时是false4.2guess被初始化为1到100之间的数都是错误的,因为这都是要猜的数。4.3a)和b)循环无数次;c)循环9次输出是3,5,7,9一行输出一个数。4.4publicclasstest3{publicstaticvoidmain(String[]args){java.util.Scannerinput=newjava.util.Scanner(System.in);intsum=0;intnumber;do{System.out.pri 阅读全文
posted @ 2013-01-27 19:42 bailun 阅读(2193) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter4; 2 3 public class FutureTuition { 4 public static void main(String[] args){ 5 double tuition = 10000; 6 int year = 1; 7 while (tuition < 20000){ 8 tuition = tuition * 1.07; 9 year++;10 }11 System.out.println("Tuitio... 阅读全文
posted @ 2013-01-27 19:39 bailun 阅读(2477) 评论(5) 推荐(0) 编辑
  2013年1月23日
摘要: 1 package 编程练习题chapter3; 2 import java.util.Scanner; 3 public class Exercise3_1 { 4 public static void main(String[] args){ 5 Scanner input = new Scanner(System.in); 6 System.out.print("Enter a, b, c: "); 7 double a = input.nextDouble(); 8 double b = input.nextDouble(); 9 ... 阅读全文
posted @ 2013-01-23 21:36 bailun 阅读(3188) 评论(1) 推荐(0) 编辑
摘要: 3.1<;<=;==;!=;>;>=3.2不能转换。布尔型不能转换到其它类型。3.3Ifnumberis30,(a)displays30iseven30isodd(b)displays30isevenIfnumberis35,(a)displays35isodd(b)displays35isodd3.4第一个没有输出。第二个输出是:zis7。第三个输出是:xis2。3.5B和C的缩进对。3.6第一个没有输出。第二个输出是:xis3。第三个输出是:zis6。3.7Yes3.80.5;0.0;0.2343.9(int)(Math.random()*20)10+(int)(M 阅读全文
posted @ 2013-01-23 21:27 bailun 阅读(2602) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter3; 2 import javax.swing.*; 3 public class AdditionTutor { 4 public static void main(String[] args){ 5 int number1 = (int)(System.currentTimeMillis() % 10); 6 int number2 = (int)(System.currentTimeMillis() * 7 % 10); 7 8 String answerString = JOptionPane.showInput... 阅读全文
posted @ 2013-01-23 21:26 bailun 阅读(1132) 评论(0) 推荐(0) 编辑
  2013年1月13日
摘要: public class Exercise2_1 { //将摄氏温度转换为华氏温度。 public static void main(String[] args){ java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter a temperature in Celsius: "); double celsius = input.nextDouble(); double fahrenheit = (9.0 / 5) * c... 阅读全文
posted @ 2013-01-13 23:00 bailun 阅读(3037) 评论(7) 推荐(1) 编辑
  2012年12月24日
摘要: 2.1关键字:class,public, int 合法的:applet, Applet, $4, apps, x, y, radius 不合法的:a++, --a, 4#R, #442,class,public, int。2.2double miles = 100;final double KILOMETERS_PER_MILE = 1.609;double kilometers =KILOMETERS_PER_MILE * miles;System.out.println(kilometers);2.3使用常量有三个好处:(1)你不重复键入相同的值;(2)如果必要的话,值只需在一个地方... 阅读全文
posted @ 2012-12-24 14:09 bailun 阅读(1958) 评论(0) 推荐(0) 编辑
  2012年12月22日
摘要: 1.1publicclassExercise1_1{publicstaticvoidmain(String[]args){System.out.println("welcometoJava");System.out.println("WelcometoComputerScience");System.out.println("Programmingisfun");} }1.2publicclassExercise1_2{publicstaticvoidmain(String[]args){for(inti=0;i<5;i++) 阅读全文
posted @ 2012-12-22 17:51 bailun 阅读(2373) 评论(1) 推荐(1) 编辑
摘要: 1.1计算机是一种电子装置,存储和处理数据。一台计算机包括硬件和软件。在一般情况下,硬件是可以看到的计算机的物理方面的,而软件是无形的指令,控制硬件和它的工作。1.2一台计算机的硬件包括一个CPU,高速缓存,内存,硬盘,软盘,显示器,打印机,通信设备。1.3机器语言是每个计算机中内置的一组基本指令。汇编语言是一种低级别的编程语言,是用一个助记符来表示各机器语言指令。高级程序设计语言是像英语那样的易于学习和运行。1.4源程序是指用高级语言编写的程序。编译器是一个程序,它把高级语言源程序翻译成等价的低级语言目标程序。1.5Java源程序被编译成字节码。JVM是Java字节码解释器。1.6操作系统是 阅读全文
posted @ 2012-12-22 15:28 bailun 阅读(1804) 评论(2) 推荐(1) 编辑