- 105
- 1
- 约4.83万字
- 约 49页
- 2015-09-06 发布于重庆
- 举报
java大学实用教程(第二版)课后编程题答案.doc
习题解答
第一章 作业题
1.
public class Hello{
public static void main (String args[ ]){
System.out.pintln(“早上好,good Morning”);
}
}
2.
import java.applet.*;
import java.awt.*;
public class Boy extends Applet {
public void paint(Graphics g) {
g.setColor(Color.blue);
g.drawString(你好,hello,12,30);
}
}
第二章 作业题
1.
public class ZuoYe2_1{
public static void main (String args[ ]){
char c=а;
System.out.println(字母+c+在unicode表中的顺序位置:+(int)c);
System.out.println(字母表:);
while(c=я){
System.out.print( +c);
c=(char)(c+1);
}
}
}
2.
import java.util.*;
public class ZuoYe2_2{
public static void main (String args[ ]){
Scanner reader=new Scanner(System.in);
long chengji=1;
int m=0;
while(reader.hasNextInt()){
int x=reader.nextInt();
m=m+1;
chengji=chengji*x;
}
System.out.println(m+个数的乘积为+chengji);
}
}
第三章 作业题
1.
import java.util.*;
public class ZuoYe3_1{
public static void main (String args[ ]){
Scanner reader=new Scanner(System.in);
double y=0,x=0;
x=reader.nextDouble();
if(x0)
y=-1+2*x;
else if(x==0)
y=-1;
else if(x0)
y=-1+3*x;
System.out.println(y);
}
}
2.
public class ZuoYe3_2{
public static void main(String args[]){
int sum=0,m=3,n=7,a=1;
while(a=1000){
if(a%m==0a%n==0)
sum=sum+a;
a++;
}
System.out.println(sum=+sum);
}
}
3.
public class ZuoYe3_3
{
public static void main(String args[])
{
long sum=0,a=8,item=a,n=10,i=1;
for(i=1;i=n;i++)
{ sum=sum+item;
item=item*10+a;
}
System.out.println(sum);
}
}
4.
public class ZuoYe3_4
{
public static void main(String args[])
{
double sum=0,a=1,b=1,fuhao=1,item=a/b;
int i=1;
while(i=1000)
{
sum=sum+fuhao*item;
i++;
您可能关注的文档
- 9103.计算机病毒与防范技术.pdf
- 9146.CorelDRAWX4图形制作实用教程.pdf
- 9151.计算机技术与应用进展2007(套装上下册).pdf
- 9155.计算机技术与应用进展2006(套装上下册).pdf
- 9179.计算机硬件技术基础实验指导.pdf
- 9185.三维计算机辅助设计教程ProENGINEER上机实用指导手册.pdf
- 9300.计算机实用技术.pdf
- 9450.计算机实用技术.pdf
- 9492.全国计算机技术与软件专业技术资格考试参考用书考点串讲真题详解与强化训练软件设计师考试同步辅导.pdf
- 9493.全国计算机技术与软件专业技术资格考试参考用书考点串讲真题详解与强化训练程序员考试同步辅导.pdf
原创力文档

文档评论(0)