Grading system in C++

后端 未结 3 2096
故里飘歌
故里飘歌 2021-01-19 07:36

So this is my C++ question :

Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D and F, possibly followed by + or -. Th

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-19 08:22

    If the input is A+ or B-, then it is not a character anymore. So, get it using a string of chars, and check the values.

    char a[3];
    float m,n;
    cin>>a;
    if(a[1]=='+')
       m=0.3;
    else if (a[1]=='-')
       m=-0.3;
    else
        m=0;
    switch(a[0])
    {
      //Assign the value of n as 4,3,2,1 depending upon the grade.
    }
    cout<

    will print the grade

提交回复
热议问题