Tax initiation: 3000
SQL code
Create or replace function tax (v_salary in number) return number is
V_expense number;
-- Deduction for quick calculation at this level = maximum income at the upper level × (current tax rate-higher tax rate) + deduction for quick calculation at the upper level
V_quick_deduction number: = 0;
V_temp number;
Begin
V_temp: = Vanderbilt salary-3000;
If v_temp = 1500 then
V_temp: = v_temp * 0.05;
Elsif v_temp> 1500 and v_temp <= 4500 then
V_temp: = v_temp * 0.1;
V_quick_deduction: = 1500 * (0.1-0.05) + 0;
Elsif v_temp> 4500 and v_temp <= 9000 then
V_temp: = v_temp * 0.2;
V_quick_deduction: = 4500 * (0.2-0.1) + 1500*(0.1-0.05 );
Elsif v_temp> 9000 and v_temp <= 35000 then
V_temp: = v_temp * 0.25;
V_quick_deduction: = 9000 * (0.25-0.2) + 4500*(0.2-0.1 );
Elsif v_temp> 35000 and v_temp <= 55000 then
V_temp: = v_temp * 0.3;
V_quick_deduction: = 35000 * (0.3-0.25) + 9000*(0.25-0.2 );
Elsif v_temp> 55000 and v_temp <= 80000 then
V_temp: = v_temp * 0.35;
V_quick_deduction: = 55000 * (0.35-0.3) + 35000*(0.3-0.25 );
Elsif v_temp & gt; 80000 then
V_temp: = v_temp * 0.45;
V_quick_deduction: = 80000 * (0.45-0.35) + 55000*(0.35-0.3 );
Else
Dbms_output.put_line (you will not be charged if you come in !);
V_temp: = 0;
End if;
V_expense: = v_temp-v_quick_deduction;
Return (v_expense );
End tax;
Create or replace function tax (v_salary in number) return number is
V_expense number;
-- Deduction for quick calculation at this level = maximum income at the upper level × (current tax rate-higher tax rate) + deduction for quick calculation at the upper level
V_quick_deduction number: = 0;
V_temp number;
Begin
V_temp: = Vanderbilt salary-3000;
If v_temp = 1500 then
V_temp: = v_temp * 0.05;
Elsif v_temp> 1500 and v_temp <= 4500 then
V_temp: = v_temp * 0.1;
V_quick_deduction: = 1500 * (0.1-0.05) + 0;
Elsif v_temp> 4500 and v_temp <= 9000 then
V_temp: = v_temp * 0.2;
V_quick_deduction: = 4500 * (0.2-0.1) + 1500*(0.1-0.05 );
Elsif v_temp> 9000 and v_temp <= 35000 then
V_temp: = v_temp * 0.25;
V_quick_deduction: = 9000 * (0.25-0.2) + 4500*(0.2-0.1 );
Elsif v_temp> 35000 and v_temp <= 55000 then
V_temp: = v_temp * 0.3;
V_quick_deduction: = 35000 * (0.3-0.25) + 9000*(0.25-0.2 );
Elsif v_temp> 55000 and v_temp <= 80000 then
V_temp: = v_temp * 0.35;
V_quick_deduction: = 55000 * (0.35-0.3) + 35000*(0.3-0.25 );
Elsif v_temp & gt; 80000 then
V_temp: = v_temp * 0.45;
V_quick_deduction: = 80000 * (0.45-0.35) + 55000*(0.35-0.3 );
Else
Dbms_output.put_line (you will not be charged if you come in !);
V_temp: = 0;
End if;
V_expense: = v_temp-v_quick_deduction;
Return (v_expense );
End tax; test: select tax (5000) from dual;
Result: 125