彭国伦教材P98课后第三题
彭国伦教材P98课后第三题,所得税有三个等级,岁年龄不同有不同算法。求教我的程序错在哪里end case 改为 end select vvt 发表于 2020-6-30 10:31
end case 改为 end select
改了,还是有两个问题
错误 1 error #5082: Syntax error, found IDENTIFIER 'TAX' when expecting one of: THEN
错误 2 Compilation Aborted (code 1)
重新给你改正后的代码。尽可能复制粘贴(不截图) 好的
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)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 15235312522 发表于 2020-6-30 16:32
好的
program test0503
implicit none
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 收到,程序正常了,谢谢老师
页:
[1]