Fortran Coder

彭国伦教材P98课后第三题

查看数: 8712 | 评论数: 6 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2020-6-30 09:47

正文摘要:

彭国伦教材P98课后第三题,所得税有三个等级,岁年龄不同有不同算法。求教我的程序错在哪里

回复

15235312522 发表于 2020-6-30 17:44:48
收到,程序正常了,谢谢老师
Transpose 发表于 2020-6-30 17:21:04
15235312522 发表于 2020-6-30 16:32
好的
program test0503
implicit none

[Fortran] 纯文本查看 复制代码
01program test0503
02implicit none
03integer age
04real income,tax
05 
06write(*,*) "Input your age:"
07read(*,*) age
08write(*,*) "Input your income:"
09read(*,*) income
10 
11select case(age)
12case(0:49)
13if(income>=0.0.and.income<=1000.0) then
14  tax=income*0.03
15else if(income>1000.0.and.income<=5000.0) then
16  tax=income*0.10
17else if(income>5000.0) then
18  tax=income*0.15
19else if(income<0.0) then
20!这个地方用了elseif就要用then
21 tax=0
22end if
23case(50:)
24if(income>=0.0.and.income<=1000.0) tax=income*0.05
25if(income>1000.0.and.income<=5000.0) tax=income*0.07
26if(income>5000.0) tax=income*0.10
27if(income<0.0)  tax=0
28case default
29  tax=0
30end select
31 
32write(*,*) "Tax:"
33write(*,*) tax
34 
35stop
36end
15235312522 发表于 2020-6-30 16:32:35
好的
[Fortran] 纯文本查看 复制代码
01program test0503
02implicit none
03integer age
04real income,tax
05 
06write(*,*) "Input your age:"
07read(*,*) age
08write(*,*) "Input your income:"
09read(*,*) income
10 
11select case(age)
12case(0:49)
13if(income>=0.0.and.income<=1000.0) then
14  tax=income*0.03
15else if(income>1000.0.and.income<=5000.0) then
16  tax=income*0.10
17else if(income>5000.0) then
18  tax=income*0.15
19else if(income<0.0)  tax=0
20end if
21case(50:)
22if(income>=0.0.and.income<=1000.0) tax=income*0.05
23if(income>1000.0.and.income<=5000.0) tax=income*0.07
24if(income>5000.0) tax=income*0.10
25if(income<0.0)  tax=0
26case default
27  tax=0
28end select
29 
30write(*,*) "Tax:"
31write(*,*) tax
32 
33stop
34end
vvt 发表于 2020-6-30 14:17:55
重新给你改正后的代码。尽可能复制粘贴(不截图)
15235312522 发表于 2020-6-30 11:23:48
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)       
vvt 发表于 2020-6-30 10:31:09
end case 改为 end select

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

GMT+8, 2025-5-5 04:45

Powered by Discuz! X3.4

© 2013-2025 Comsenz Inc.

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