实用教程耿祥义张跃平java大学实用教程编程题答案

java实用教程  时间:2021-02-13  阅读:()

耿祥义张跃平java大学实用教程编程题答案

习题解答

第一章作业题

1 pu   icc   ss el   

 ubl  csta  i  void ma  n ( tr  ng args[  ) 

System o  tpi  tln(“早上好,goo Morning”)

}

2。

 mport ja  a  ap  l  t。 import   v  awt。 p  bl ic  lass  oy e  tendsAp  l  t pu   icvoi  p  int rap     ) {g。 s  tColor olo  。 blue)g。 dr w   ing(”你好 hel lo" 12 30 

}

第二章作业题

1 publ icclass Zuoe2_1{pub  icst  ticvoi main (Stri  g  r s   ) ch   c=  а’ 

Sy  t out  prin   n("字母 c+ 在 n   ode表中的顺序位置 ” i  t c);

Sy  te。 out。 println("字母表   ;whi le c<=’я’ 

System out  pri  t ” "c);

耿祥义张跃平java大学实用教程编程题答案c=    ar (c1 

}

}

}

 impor   a   uti l*;pu  l ic class ZuoYe2_ 

     c s  a  i  v id    ( tring  rgs    

 cann  r r  ade =new   anner(Syst i  ;lo  g chengj i= ;

 nt =whi le   ea  er hasNext  nt ) {int x=  eade  。   xt  nt( m=m1;

 heng   c   ngj i*x;

Sys  em。  ut。 p r  n  l (m+"个数的乘积为"  h e  g  i);}

}

第三章作业题

 import jav   ut   。 *;

 u  l i  c  ass Zuo 3_1{

 ubl  cstat   voi main Str  ng ar s   ) 

Scan    re  der=new  a  ner(Syst m in doubl  y , 0;x=readernex  Double )if x 〈0)y=-1+2*xels  i    0)y=—1;else i  (x0

 -1+3x;

Sy   em out  r  ntln(y 

}

}

耿祥义张跃平java大学实用教程编程题答案

 publ i  classuYe3_2{pub  icstaticvoi  i (St  i  g arg  [ ){

 nts =0 =3,n7 a1w i le(a 〈=100  if a==0&a%n==0)

 m= u+;a+

}

System out    i   ln "s m=  + um }

}

3。pub  ic classZ Ye3_3

publ ic sta  ic vo  d main St   nga  gs[ )

longsum=0,a ,  te=a n=  i  

 or(i=1  <=n i++)

{ sum  um+itemitem= t m*10a

Sy  te ut。   i  tln sum 

}

4

 u  l icc  a   Zu e3_4

{

  bl  c static  id ma  (   ing  rg  ]{

   blesum= a  ,b=1 fuhao= , itea/b

 n  i=1whi le(i= 000)

su= um+f  h  oit m;i++;fu  a =fu  ao(-1 b=  itema/b

耿祥义张跃平java大学实用教程编程题答案

System ut pri  t  n ”  =  + um }

}

5 publ   class ZuoYe3_5

{p  b  ic  ta  i  voi main String ar s   {

    lesum=0 a= ;in  i1whi l (i<= 0

if(i〉 = 0)sum= mai+a=ai ;

Systemut。  rin  l (”sum="+s )

 

第四章作业题

1 

 lass  gCh  int  tar   d;

Den  Ch ( {

}

De  gCh (int start  nt d t   s。 start= t  rtthi  d=;

void se  Sta  t in  s){s   r    

耿祥义张跃平java大学实用教程编程题答案v id set(int ){

   s。 d=d;

 nt get  (i   n i  t  um= i= ;

hi le(  <= sum=sum+   rtsta  = tart+;i+;

}re  urn  m;

}p  bl ic   ass ZuoY_1

{p   l icsta  i  vo  d m in String  r   ]{

Dengha  hul ie=ne Dengha(2,3);

Sy   em out  pri  tln s   l i  g    um   00) ;  ul  e  s   Start(1  shul ie  s   D();

Systemut  p  i  tln(  hul i  ge   um 9));

}

.clas  Lett  r publ  c  o    rintLetter ){

 or ch  rc=  '  c='z' ;c+)

Syst u   ri nt(” ”+)

pub  ic  lass Zu 4_2

publ icstat  cv i m i  (String  rg  [  )

{

L  t   rp= w L   te  ()p  printLetter( 

耿祥义张跃平java大学实用教程编程题答案

3.class S   areEquatio  doublea b;stati  doub  e cdo  ble  oot1  oot2boole    oo

 ubl i  Squ   eE  ua     do  bl  a doubleb,double c th  s。 a=a;

  isb=;

S  uare  qu  t  on  =cif a =0 {botrue

}else boo=f  lse

}

 u  l i  void g   Roots  

  bo 

Sys  em out pri   ln ”是一元次方程” ;doub     skb 4*aci  di  k〉  ) 

 oot1=(b+M  h。 s r  (disk ) *a root2=  —a    qr  (disk  /(2a 

 ys  em。 o  t 。 p r  ntf("方程的根 f  %f n",root1,root2 ;

else{

 ysteou   r  ntf "方程没有实根\” ;

}

else{

Sys  e ut   ri  tl  ”不是一元2次方程” 

pu  l  c voids   Coefficie  t double ,dou  le b d  ublec 

耿祥义张跃平java大学实用教程编程题答案

 his  a=;

 his。 b 

Sq   reEquat  onc=c;i  a =0){boo=true

}e  se 

 o=false

p  bl iccl   sZ oe4_3{

 ub  ic st  t  cvoid ain Str  ng   gs[   {

Squar  Eq  a  ion eq  at   n1  ew Square  quatio  4,,1)

Sq   reEquati     uat   n2new   ua  e   ation 3 5 7 ;equ  t  on1  g  tRots )

 quation2  ge   ot  )

}

4

 mport java。 u  i l。 Scanner

 lass A{i  t f in  m,  ntn i  m*n 

{ System out。  rintl ( 有负数程序退出  

 yst m。 e  it(0 ;

 f( )

{ int temp=mm=;ntemp

 nt a=,=;int =;whi le r!=0

 =

=  

耿祥义张跃平java大学实用教程编程题答案r=m;

}re   rn n;

cl  ss  

A a

B ) 

=new A( ;

}intg in   intn {in   emp=a  f m );

 etur n/temp;

}

 ub    cla  s uoYe44

pub  icsta  ic  oi main String args[ ]

{

Scanner rea   =new Scan   r(S stem。 in 

 ystem out p  i  tl  ”输入2个正整数程序计算出它们的最大公约数和最小公倍数");

Sy  teut  p  int  输入第一个整数 " 

 nt m=r  ader。  ex  Int  ;

 yste。   t   in  (”输入第二个整数:” int n=rea  er  extInt  

 =ne   

Bb=neB( 

   t mout。  r  ntln(+ 和"+  +"的最大公约数是+a。 f m,n )

 ystem o  t println m+”和 n"的最小公倍数是 +b。 g(m,n));

 im ort java。 applet  pplet;

 mpor  jav   awt。 *publ icc  as    am le10 exten  s plet

耿祥义张跃平java大学实用教程编程题答案

 ut    redbutton;pu  l ic voi  i  i  (

r  dbut  on=new  utt n "我是一个红色的按钮")r   bu   on  e  B  ckgrou  d Cl r  e );r   button s  tF regro  n  Co  orwhite);add r  d  utton)

}

第五章作业题

1 import   v  。 uti l Sca  ner

 las  A

publ i  in  f intm intn

{if(m<n

{int  ep=mm=

   ep

 nt r=mn;whi l (r =0)

m=n

 r;r=mn;

}

 e  u  n n;

}

}class  ext  nds A

{publ  c  nt f(int m, intn

#消息# contabo:德国老牌机房新增美国“纽约、西雅图”数据中心,免设置费

运作了18年的德国老牌机房contabo在继去年4月开办了第一个美国数据中心(中部城市:圣路易斯)后立马在本月全新上马两个数据中心:纽约、西雅图。当前,为庆祝美国独立日,美国三个数据中心的VPS全部免除设置费,VPS本身的配置很高,价格适中,有较高的性价比!官方网站:https://contabo.com/en/SSD VPSKVM虚拟,纯SSD阵列,不限制流量,自带一个IPv4内存CPUSSD带...

PIGYun中秋特惠:香港/韩国VPS月付14元起

PIGYun发布了九月份及中秋节特惠活动,提供8折优惠码,本月商家主推中国香港和韩国机房,优惠后最低韩国每月14元/中国香港每月19元起。这是一家成立于2019年的国人商家,提供中国香港、韩国和美国等地区机房VPS主机,基于KVM架构,采用SSD硬盘,CN2+BGP线路(美国为CUVIP-AS9929、GIA等)。下面列出两款主机配置信息。机房:中国香港CPU:1core内存:1GB硬盘:10GB...

wordpress外贸企业主题 wordpress高级全行业大气外贸主题

wordpress高级全行业大气外贸主题,wordpress通用全行业高级外贸企业在线询单自适应主题建站程序,完善的外贸企业建站功能模块 + 高效通用的后台自定义设置,更实用的移动设备特色功能模块 + 更适于欧美国外用户操作体验 大气简洁的网站风格设计 + 高效优化的网站程序结构,更利于Goolge等SEO搜索优化和站点收录排名。点击进入:wordpress高级全行业大气外贸主题主题价格:¥398...

java实用教程为你推荐
qq讨论组qq讨论组是什么?为什么我的好友都能看见我说话?网页解密如何查看网页中的密码google竞价排名谷歌SEO与谷歌竞价的区别和联系伪装微信地理位置如何用伪装微信地理位置?缓冲区溢出教程溢出攻击原理手机区号手机号码前怎样填写正确的国内区号?童之磊网文大学很强吗?天天酷跑刷金币天天酷跑怎么刷金币?神雕侠侣礼包大全神雕侠侣先手礼包在哪领迅雷云点播账号求一个迅雷云点播vip的账号,只是看的,绝不动任何手脚。
网站服务器租用 seovip dropbox网盘 卡巴斯基试用版 umax120 多线空间 英雄联盟台服官网 域名转入 阿里云个人邮箱 数据湾 葫芦机 asp介绍 tracert screen hp存储服务器 qq空间排行榜 正在登陆游戏服务器 万根云主机 电脑主机报警 淘宝vip购优汇 更多