「已注销」 2018-10-19 07:49 采纳率: 33.3%
浏览 856
已结题

Fortran的一道简单的编程题目

要求:写一个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条回答 默认 最新

  • devmiao 2018-10-27 04:49
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题