5.2.1 Use the ELSIF StatementIn this exercise, you will use an ELSIF statement to display a letter grade for a student registered for a specific section of course number 25. Create the following PL/SQL script: -- ch05_3a.sql, version 1.0 SET SERVEROUTPUT ON DECLARE v_student_id NUMBER := 102; v_section_id NUMBER := 89; v_final_grade NUMBER; v_letter_grade CHAR(1); BEGIN SELECT final_grade INTO v_final_grade FROM enrollment WHERE student_id = v_student_id AND section_id = v_section_id; IF v_final_grade BETWEEN 90 AND 100 THEN v_letter_grade := 'A'; ELSIF v_final_grade BETWEEN 80 AND 89 THEN v_letter_grade := 'B'; ELSIF v_final_grade BETWEEN 70 AND 79 THEN v_letter_grade := 'C'; ELSIF v_final_grade BETWEEN 60 AND 69 THEN v_letter_grade := 'D'; ELSE v_letter_grade := 'F'; END IF; -- control resumes here DBMS_OUTPUT.PUT_LINE ('Letter grade is: ' v_letter_grade); END; Note, that you may need to change the values for the variables v_student_id and v_section_id as you see fit in order to test some of your answers. Try to answer the following questions first, and then execute the script:
|