JAVA2
简明教程习题答案
第二章
课堂习题
: public class Main
{
public static void main(String[] args) { //initialization phase
初始段
float f1 = 2.5f;
float f2;
int a = 7;
int b = 2;
int c;
//processing phase
处理段
f2 = f1 + (a/b);
c = (a/b);
//termination phase
System.out.println("f2
System.out.println("c
}
课后习题
: 2-4
(
小程序部分
) import java.applet.*; import java.awt.*;
public class Gess extends Applet
{
public void paint(Graphics g)
{
//3~10000
中的任意数
int m = 20;
int n = 9993;
g.drawString("
本程序仅对
3~10000
中任意取的整数
: ",80,50); g.drawString("20" ,80,65);
终止段
的值为
: " +
f2);
的值为
: "
+ c);