习题解答
第一章 作业题
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) {
cms系统主要做什么 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 Int();
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;
Double();
if(x<0)
y=-1+2*x;
else if(x==0)
y=-1;
else if(x>0)fifo管理什么意思
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==0&&a%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.
java经典上机编程题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++;安卓登录界面代码
fuhao=fuhao*(-1);
b=b+2;
item=a/b;
}
System.out.println("sum="+sum);
}
}
5.
public class ZuoYe3_5
{
public static void main(String args[])
{
double sum=0,a=1;
int i=1;
while(i<=20)
{
if(i>=10)
sum=sum+a;
i++;
a=a*i;
web安全怎么学 }
System.out.println("sum="+sum);
}
}
8.
第四章 作业题
1.
class DengCha{
int start,d;
DengCha(){
}
DengCha(int start,int d){
this.start=start;二叉树遍历每个节点经过几遍
this.d=d;
}
void setStart(int s){
start=s;
}
void setD(int d){
this.d=d;
}
int getSum(int n){
int sum=0,i=1;
while(i<=n){
sum=sum+start;
start=start+d;
i++;
}
return sum;
}
}
public class ZuoYe4_1
{
public static void main (String args[ ])
{
DengCha shulie=new DengCha(2,3);
System.out.Sum(100));
shulie.setStart(10);
shulie.setD(5);
System.out.Sum(9));
}
}
2.
class Letter{
public void printLetter(){
for(char c='a';c<='z';c++)
System.out.print(" "+c);
}
}
public class ZuoYe4_2
{
public static void main (String args[ ])
{
Letter p=new Letter();
p.printLetter();
}
}
3.
class SquareEquation{
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论