w3resource

PL/SQL Control Statement Exercises: Display the description against a grade

PL/SQL Control Statement: Exercise-8 with Solution

Write a PL/SQL program to display the description against a grade.

Sample Solution:

PL/SQL Code:

DECLARE
    grd CHAR(1);
  BEGIN
    -- Accept value for grade
    grd := '&new_grd';
    IF grd = 'A' THEN
      dbms_output.Put_line('Your Grade is: Outstanding');
    ELSIF grd = 'B' THEN
      dbms_output.Put_line('Your Grade is: Excellent');
    ELSIF grd = 'C' THEN
      dbms_output.Put_line('Your Grade is: Very Good');
    ELSIF grd = 'D' THEN
      dbms_output. Put_line('Your Grade is: Average');
    ELSIF grd = 'F' THEN
      dbms_output.Put_line('Your Grade is: Poor');
    ELSE
      dbms_output.Put_line('No such grade in the list.');
    END IF;
  END;
/

Sample Output:

Enter value for new_grd: A
old   5:   grd := '&new_grd';
new   5:   grd := 'A';
Your Grade is: Outstanding

PL/SQL procedure successfully completed.

Flowchart:

Flowchart: PL/SQL Control Statement Exercises: Display the description against a grade

Improve this sample solution and post your code through Disqus

Previous: Write a PL/SQL program to count number of employees in department 50 and check whether this department have any vacancies or not. There are 45 vacancies in this department.
Next: Write a PL/SQL program to count number of employees in a specific department and check whether this department have any vacancies or not. If any vacancies, how many vacancies are in that department.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/plsql-exercises/control-statement/plsql-control-statement-exercise-8.php