Fortran的一道简单的编程题目 5C

要求:写一个Fortran90 fixed format程序,名字:student_info.F,包括内容如下:
建一个学生档案,学生的信息包括学号(整型),计算机成绩(实型),同时这些信息从屏幕(log in node)读入,读入后进行判断:如果成绩高于90分,输出“excellent”,如果是80-89,输出“Good”,如果是“60-79”,输出“Fair”,其余的输出“Fail”
我写的代码如下:
program assignment3
type :: person
integer :: schoolnumber
real :: score
character :: grade

    end type person
    type (person) :: a

    character(len=12) b
    character(len=10) c
    character(len=10) d
    character(len=10) e
     b = "Excellent!"
     c = "Good!"
     d = "Fair!"
     e = "Fail!"

    write(*,*) "School number:"
    read(*,*) a%schoolnumber
    write(*,*) "Score:"
    read(*,*) a%score

    if (score >= 90) then
    grade = "b"
    else if (score >= 80) then
    grade = "c"
    else if (score >= 60) then
    grade = "d"
    else if (score >= 0) then
    grade = "e"
    else
    grade = '?'
    end if

    write(*,"('Grade:',A10)") a%grade


    write(*,100) a%schoolnumber,a%score,a%grade

100 format(/,"School number:",A10/,"Score:",A2/,"Grade:",A10)

    end

请问如何修改呢?

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!