Fortran Coder

查看: 7764|回复: 6
打印 上一主题 下一主题

[读物] 彭国伦教材P98课后第三题

[复制链接]

159

帖子

2

主题

1

精华

大师

Vim

F 币
961 元
贡献
469 点

规矩勋章

楼主
发表于 2020-6-30 17:21:04 | 显示全部楼层
15235312522 发表于 2020-6-30 16:32
好的
program test0503
implicit none

[Fortran] 纯文本查看 复制代码
program test0503
implicit none
integer age
real income,tax

write(*,*) "Input your age:"
read(*,*) age
write(*,*) "Input your income:"
read(*,*) income

select case(age)
case(0:49)
if(income>=0.0.and.income<=1000.0) then
  tax=income*0.03
else if(income>1000.0.and.income<=5000.0) then
  tax=income*0.10
else if(income>5000.0) then
  tax=income*0.15
else if(income<0.0) then
!这个地方用了elseif就要用then
 tax=0
end if
case(50:)
if(income>=0.0.and.income<=1000.0) tax=income*0.05
if(income>1000.0.and.income<=5000.0) tax=income*0.07
if(income>5000.0) tax=income*0.10
if(income<0.0)  tax=0
case default
  tax=0
end select

write(*,*) "Tax:"
write(*,*) tax

stop
end
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-6 06:23

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表