资源描述:
《Fortran95程序设计课后习题答案word版方便.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、第四章1.programmainimplicitnonewrite(*,*)"Haveagoodtime."write(*,*)"That'snotbad."write(*,*)'"Mary"isn''tmyname.'endprogram2.programmainreal,parameter::PI=3implicitnone.14159realradiuswrite(*,*)"请输入半径长"read(*,*)radiuswrite(*,"('面积='f8.3)")radius*radius*PIendprogram3.programmai
2、nimplicitnonerealgradeswrite(*,*)"请输入成绩"read(*,*)gradeswrite(*,"('调整后成绩为'f8.3)")SQRT(grades)*10.0endprogram4.integera,brealra,rba=2b=3ra=2.0rb=3.0write(*,*)b/a!输出1,因为使用整数计算,小数部分会无条件舍去write(*,*)rb/ra!输出1.55.programmainimplicitnonetypedistancerealmeter,inch,cmendtypetype(dist
3、ance)::dwrite(*,*)"请输入长度:"read(*,*)d%meterd%cm=d%meter*100d%inch=d%cm/2.54write(*,"(f8.3'米='f8.3'厘米='f8.3'英寸')")d%meter,d%cm,d%inchendprogram第五章1.programmainimplicitnoneintegermoneyrealtaxwrite(*,*)"请输入月收入"read(*,*)moneyif(money<1000)thentax=0.03elseif(money<5000)thentax=0.
4、1elsetax=0.15endifwrite(*,"('税金为'I8)")nint(money*tax)endprogram2.programmainimplicitnoneintegerdaycharacter(len=20)::tvwrite(*,*)"请输入星期几"read(*,*)dayselectcase(day)case(1,4)tv="新闻"case(2,5)tv="电视剧"case(3,6)tv="卡通"case(7)tv="电影"casedefaultwrite(*,*)"错误的输入"stopendselectwrite(
5、*,*)tvendprogram3.programmainimplicitnoneintegerage,moneyrealtaxwrite(*,*)"请输入年龄"read(*,*)agewrite(*,*)"请输入月收入"read(*,*)moneyif(age<50)thenif(money<1000)thentax=0.03elseif(money<5000)thentax=0.10elsetax=0.15endifelseif(money<1000)thentax=0.5elseif(money<5000)thentax=0.7else
6、tax=0.10endifendifwrite(*,"('税金为'I8)")nint(money*tax)endprogram4.programmainimplicitnoneintegeryear,dayslogicalmod_4,mod_100,mod_400write(*,*)"请输入年份"read(*,*)yearmod_4=(MOD(year,4)==0)mod_100=(MOD(year,100)==0)mod_400=(MOD(year,400)==0)if((mod_4.NEQV.mod_100).or.mod_400)the
7、ndays=366elsedays=365endifwrite(*,"('这一年有'I3'天')")daysstopendprogram第六章1.programmainimplicitnoneintegeridoi=1,5write(*,*)"Fortran"enddostopendprogram2.programmainimplicitnoneintegeri,sumsum=0doi=1,99,2sum=sum+ienddowrite(*,*)sumstopendprogram3.programmainimplicitnoneinteger
8、,parameter::answer=45integer,parameter::max=5integerweight,idoi=1,maxwrite(*,*)"请输