العملى Write a program takes two numbers from user to calculate power. Ex:First number 5 Second number 3 Result is 5*5*5 = 125 Output is power is 125 Scanner user=new Scanner(System.in); System.out.println("base: "); int bas=user.nextInt(); System.out.println("power: "); int power=user.nextInt(); int x=1; for(int i=1;i<=power;i++){ x*=bas; } System.out.println("power= "+x); } Write a program takes number from user to calculate factorial. Ex:Number 5 Result is 5*4*3*2*1 = 120 Output is factorial for number 5 is 120 Scanner user=new Scanner(System.in); System.out.println("base: "); int fact=user.nextInt(); int x=1; for(int i=1;i<=fact;i++){ x*=i; } System.out.println("power= "+x); } Write a program to find sum of all odd numbers between 1 to 20. int x=0; for(int i=1;i<=20;i++){ if(i%2!=0){ x+=i; System.out.println(i); } } System.out.println("sum= "+x); } Write a program to find sum of all even number between 1 to 20 int x=0; for(int i=1;i<=20;i++){ if(i%2==0){ x+=i; System.out.println(i); } } System.out.println("sum= "+x); } Write a PL/SQL block: To find the number of airports from the countries table for a supplied country_name. Based on this number, display a customized message as follows: # Airports Message 0–100 There are 100 or fewer airports. 101–1,000 1001–1,0000 There are between 101 and 1,000 airports. There are between 1,001 and 10,000 airports. > 10,000 There are more than 10,000 airports. No value in database The number of airports is not available for this country. DECLARE v_country_name wf_countries.country_name%TYPE; v_airports wf_countries.airports%TYPE; v_string VARCHAR2(60); BEGIN SELECT airports INTO v_airports FROM wf_countries WHERE country_name = v_country_name; v_string := CASE WHEN v_airports < 101 THEN 'There are 100 or fewer airports.' WHEN v_airports < 1001 THEN 'There are between 101 and 1,000 airports' WHEN v_airports < 10001 THEN 'There are between 1,001 and 10,000 airports' WHEN v_airports > 10000 THEN 'There are more than 10,000 airports.' ELSE 'The number of airports is not available for this country.' END; DBMS_OUTPUT.PUT_LINE(v_string); END; Write PLSQL code that takes the grade of student and return message shows the GPA of this student. When grade is greater than 90 >> GPA is A When grade between 75 and 90 >> GPA is B When grade between 65 and 75 >> GPA is C When grade between 50 and 65 >> GPA is D When grade is less than 50 >> Failed DECLARE ;)20(v_grade varchar2 BEGIN SELECT grade INTO v_grade FROM students ;WHERE student_id = v_stundent_id =: v_grade CASE 'WHEN v_grade >90 THEN 'Gpa is A 'WHEN v_grade between 75 and 90 THEN 'Gpa B 'WHEN v_grade between 65 and 74 THEN 'Gpa C 'WHEN v_grade between 55 and 64 THEN 'Gpa D 'ELSE 'faild ;END ;DBMS_OUTPUT.PUT_LINE(v_grade) ;END use the jobs table. Create a PL/SQL block that fetches and displays the six jobs with the highest salary. For each of these jobs, display the job_id, job_title, min_salary, and max_salary. DECLARE CURSOR jobs_cursor IS SELECT * FROM jobs ORDER BY Max_salary desc; v_job jobs_cursor%ROWTYPE; BEGIN OPEN jobs_cursor; LOOP FETCH jobs_cursor INTO v_job; EXIT WHEN jobs_cursor%ROWCOUNT > 6; DBMS_OUTPUT.PUT_LINE(v_job.job_id || ' ' || v_job.job_title || ' ' || v_job.min_salary || ' ' || v_job.max_salary ); END LOOP; CLOSE jobs_cursor; END; Write a PL/SQL block to display the country_id and country_name values from the COUNTRIES table for country_id whose values range from 1 through 3. Use a basic loop. Increment a variable from 1 through 3. Use an IF statement to test your variable and EXIT the loop after you have displayed the first 3 countries. DECLARE v_id countries.country_id%TYPE:=1; v_country_name countries.country_name%TYPE; BEGIN LOOP SELECT country_name INTO v_country_name FROM countries WHERE country_id=v_id; DBMS_OUTPUT.PUT_LINE('Country id: '||v_id|| ' Country name: '||v_country_name); v_id:=v_id+1; if v_id>3 THEN EXIT; END IF; END LOOP; END; خطوات عمل الcursor وضح الفرق بينprocedure & function انواعparameters in procedure وضح انواعexception While(pre test) & do While(post test) ما هوtrigger