10-in-1
by CodeChum Admin
Troy who is in his 1st grade and is having a hard time learning how to count numbers from 0 – 50. He asked his brother Gabriel to teach him how to count, but he requested to do teach it 10 numbers per line. His brother don't know how to teach his brother so he looking for a friend who can help him. Can you help Gabriel to do a program that can teach Troy to count numbers by printing it 10 numbers per line? If the numbers exceed or is equal to 50, the output should display "Number must be below 50!".
Input
1. Size of Numbers
Description
The size of the numbers.
Constraints
The value is guaranteed to be a positive integer.
Sample
17
Output
The first line will contain a message prompt to input the size.
The succeeding lines will contain the numbers or the message required if the number is greater than 50.
Enter·size:·17
0·1·2·3·4·5·6·7·8·9
10·11·12·13·14·15·16
Make a program that will accept an integer and loop from 1 to that integer. Then, print all numbers from that range that are greater than 3.
Enter the Customer Name: Abcd
Enter the Type of Meal: 1
[1 for Meal 1 (Burger, Fries and Drinks) , 2 for Meal 2(Cheeseburger, Fries and Drinks), and 3 for Meal 3 (Spaghetti, Fries and Drinks)]
Enter the Number of Order: 2
Total Amount of Abcd order is: 140.00
Would you like to try again? (Y/N)?: y
********* Ordering System ***********
Enter the Customer Name: Def
Enter the Type of Meal: 2
[1 for Meal 1 (Burger, Fries and Drinks) , 2 for Meal 2(Cheeseburger, Fries and Drinks), and 3 for Meal 3 (Spaghetti, Fries and Drinks)]
Enter the Number of Order: 1
Total Amount of Abcd order is: 100.00
Would you like to try again? (Y/N)?: y
********* Ordering System ***********
Enter the Customer Name: Xyc
Enter the Type of Meal: 2
[1 for Meal 1 (Burger, Fries and Drinks) , 2 for Meal 2(Cheeseburger, Fries and Drinks), and 3 for Meal 3 (Spaghetti, Fries and Drinks)]
Enter the Number of Order: 1
Total Amount of Abcd order is: 100.00
Would you like to try again? (Y/N)?: n
Did you know that in lotteries, a 3-digit number with the same numbers in all digits like 777 will hit the jackpot in a casino? In the same manner, let's make a program that will test if a certain 3-digit number hits a jackpot or not by identifying if all the digits of a given number is the same as the second inputted number. If it is, print "Jackpot!"; else, print "Nah".
Let's try this out now!
Input
1. 3-digit number
2. Digit to be checked
Output
The first line will contain a message prompt to input the 3-digit integer.
The second line will contain a message prompt to input the digit to be checked.
The last line contains the appropriate string.
Explain the role and purpose of the two codes provided below. (5 marks)
Create or Replace Trigger Purchase_Entry
After Insert or Update of Purchase_Amt on PURCHASE_AGREEMENT
For Each Row
Begin
if(:New.Purchase_Amt < 0) Then
RAISE_APPLICATION_ERROR(‐20100,
'Cannot enter a purchase agreement amount less than zero.');
end if;
End;
insert into PURCHASE_AGREEMENT values (559, '27 May 2020', ‐1, 12350,'C122',1)
continuous....Write the code solution using an explicit cursor with a simple Loop. Make sure to use your own variables. (10 marks)
Assist John in understanding the different explicit cursors he can use.Using the scenario in Q2, answer the following questions.(20Marks)
Your colleague John has been struggling with a PL/SQL query that should display the CustomerID and the House Number, including the Materials used in the construction of the townhouses.Identify the errors and re‐write the correct code: set serveroutput on c_id CUSTOMER.cust_id%Type; t TOWNHOUSE.house_num%Type; m_name MATERIALS.material_name%Type;cursor info is select cu.cust_id,t.house_num, m.material_name from CUSTOMER cu, TOWNHOUSE t, MATERIALS m, PURCHASE_AGREEMENT pa where cu.cust_id = pa.cust_id and t.house_num = pa.house_num and m.material_id = pa.material_id begin for rec in info c_id:=rec.cust_id; t:=rec.house_num; m_name:=rec.material_name; dbms_output_put_line('CUSTOMER ID: ' || c_id || ', ' || chr(13) ||'HOUSE NUM: ' || t || chr(13) || 'MATERIALS: ' || m_name); dbms_output.put_line('‐‐‐‐‐‐‐'); end loop;
Identify the errors and re‐write the correct code: (10 MARKS)
set serveroutput on
c_id CUSTOMER.cust_id%Type;
t TOWNHOUSE.house_num%Type;
m_name MATERIALS.material_name%Type;
cursor info is
select cu.cust_id, t.house_num, m.material_name
from CUSTOMER cu, TOWNHOUSE t, MATERIALS m, PURCHASE_AGREEMENT pa
where cu.cust_id = pa.cust_id
and t.house_num = pa.house_num
and m.material_id = pa.material_id
begin for
rec in info
c_id:=rec.cust_id;
t:= rec.house_num;
m_name:=rec.material_name;
dbms_output_put_line('CUSTOMER ID: ' || c_id || ', ' ||
chr(13) ||'HOUSE NUM: ' || t || chr(13) || 'MATERIALS: ' || m_name);
dbms_output.put_line('‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐');
end loop;
For Apple store services and apps(like games, videos, etc ): you can gain access if you
are15years old or less and your parent has an Apple ID. If you are 16 years old or more
you need to have your own Apple ID.
Write a program that uses short circuit logic to tell someone if they are legal to gain
access to Apple store services. First ask them how old they are, whether they have an
Apple ID or not, and whether their parent has an Apple ID or not.