Thursday, October 13, 2011

IF Statement (Number 11)


Write a program to determine the equivalent grade of each student in a class as follows:


      a. Read in the student's name, midterm grade, minor B, and final exam ratings.
      b. Determine the final grade of the student by formula:
          final grade = 0.30 of midterm grade + 0.10 of minor B + 0.60 of final exam.
      c. Determine the equivalent grade for the numerical value obtained by the following grading marks:


                    98 - 100 = 4.00
                    95 - 97 = 3.75
                    92 - 94 = 3.50
                    89 - 91 = 3.25
                    86 - 88 = 3.00
                    83 - 85 = 2.75
                    80 - 82 = 2.50
                    77 - 79 = 2.25
                    74 - 76 = 2.00
                    71 - 73 = 1.75
                    68 - 70 = 1.50                   
                    64 - 67 = 1.25
                    60 - 63 = 1.00                   
                    below 60= 0.00
  
(Solution)


     #include<stdio.h>
     #include<conio.h>
     #define p printf
     #define s scanf


     int main()
     {
         int MidG, MinB, Fin;
         float FG;
         char SN;
  
         p("Enter student's name: ");
         s("%s",&SN);
         p("Enter midterm grade: ");
         s("%d",&MidG);
         p("Enter minor B: ");
         s("%d",&MinB);
         p("Enter final exam: ");
         s("%d",&Fin);
  
         fg = ( MidG * .30 ) + ( MinB * .10 ) + ( Fin * .60 );
         p("Your final grade is %.2f or equivalent to ",FG);
  
              if( FG >= 98 && FG <= 100)
                  {
                  p("4.00");
                  }
              else
              if( FG >= 95 && FG <= 97)
                  {
                  p("3.75");
                  }
              else
              if( FG >= 92 && FG <= 94)
                  {
                  p("3.50");
                  }
              else
              if( FG >= 89 && FG <= 91)
                  {
                  p("3.25");
                  }
              else
              if( FG >= 86 && FG <= 88)
                  {
                  p("3.00");
                  }
              else
              if( FG >= 83 && FG <= 85)
                  {
                  p("2.75");
                  }
              else
              if( FG >= 80 && FG <= 82)
                  {
                  p("2.50");
                  }
              else
              if( FG >= 77 && FG <= 79)
                  {
                  p("2.25");
                  }
              else
              if( FG >= 74 && FG <= 76)
                  {
                  p("2.00");
                  }
              else
              if( FG >= 71 && FG <= 73)
                  {
                  p("1.75");
                  }
              else
              if( FG >= 68 && FG <= 70)
                  {
                  p("1.50");
                  }
              else
              if( FG >= 64 && FG <= 67)
                  {
                  p("1.25");
                  }
              else
              if( FG >= 60 && FG <= 63)
                  {
                  p("1.00");
                  }
              else
                  {
                  p("0.00");
                  }
         getch ();
         return 0;
      }

0 comments:

Post a Comment