title: PL/SQL assistance to convert each student’s overall score to a letter grade
body: <p>I am trying to create a PL/SQL block that converts each student’s overall score to a letter grade by the rule 90-100=A, 80-89.99=B, 65-79.99=C, 0-64.99=F, and include the letter grade in the output. I am trying to figure out how exactly to insert an IF or CASE statement into the existing code. The output should look like the following:</p>
  
  <pre><code>445 Seinfeld 92.1 A
  909 Costanza 78.2 C
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>DROP TABLE STUDENT CASCADE CONSTRAINTS;
  CREATE TABLE STUDENT
  (
      ID      CHAR(3),
      Name        VARCHAR2(20),
      Midterm NUMBER(3,0)     CHECK (Midterm&gt;=0 AND Midterm&lt;=100),
      Final       NUMBER(3,0) CHECK (Final&gt;=0 AND Final&lt;=100),
      Homework    NUMBER(3,0) CHECK (Homework&gt;=0 AND Homework&lt;=100),
  
      PRIMARY KEY (ID)
  );
  INSERT INTO STUDENT VALUES ( '445', 'Seinfeld', 85, 90, 99 );
  INSERT INTO STUDENT VALUES ( '909', 'Costanza', 74, 72, 86 );
  INSERT INTO STUDENT VALUES ( '123', 'Benes', 93, 89, 91 );
  INSERT INTO STUDENT VALUES ( '111', 'Kramer', 99, 91, 93 );
  INSERT INTO STUDENT VALUES ( '667', 'Newman', 78, 82, 83 );
  INSERT INTO STUDENT VALUES ( '888', 'Banya', 50, 65, 50 );
  SELECT * FROM STUDENT;
  
  DROP TABLE WEIGHTS CASCADE CONSTRAINTS;
  CREATE TABLE WEIGHTS
  (
      MidPct  NUMBER(2,0) CHECK (MidPct&gt;=0 AND MidPct&lt;=100),
      FinPct  NUMBER(2,0) CHECK (FinPct&gt;=0 AND FinPct&lt;=100),
      HWPct       NUMBER(2,0) CHECK (HWPct&gt;=0 AND HWPct&lt;=100)
  );
  INSERT INTO WEIGHTS VALUES ( 30, 30, 40 );
  SELECT * FROM WEIGHTS;
  
  declare
   Midpct WEIGHTS.midpct%type;
   Finpct WEIGHTS.finpct%type;
   Hwpct WEIGHTS.hwpct%type;
  
   studentName student.name%type;
   studentID student.id%type;
   Midterm student.midterm%type;
   Final student.final%type;
   Homework student.homework%type;
   average number(5,2);
  
   cursor studentPtr is SELECT * FROM STUDENT;
  
  begin
  
    open studentPtr;
  
    loop
  
      fetch studentPtr into studentID, studentName, Midterm, Final, Homework;
      average:=(Midterm + Final + Homework)/3;
  
      if studentPtr%found then
  
                 &lt;&lt;&lt;&lt;&lt;&lt;CALCULATE LETTER GRADE HERE, I THINK????&gt;&gt;&gt;&gt;&gt;&gt;&gt;
  
            dbms_output.put_line(studentID  ||' '|| studentName|| ' '||average||' ');
  
      else`enter code here`
  
      exit;
  
          end if;
  
      end loop;
  
      close studentPtr;
  
  end;
  / 
  </code></pre>