Calculate the number of bookings that belong to each car.

Assignment Help Basic Computer Science
Reference no: EM13977148

In this assignment, you will use the CAR HIRE database. The CAR HIRE database including appropriate data will be made available on the University Oracle server. You can query these tables as if they are in your own schema but you are not permitted to insert or update data in these tables. The specification for the CAR HIRE database is as follows:

The table descriptions appear below, including the column names, data types and the meanings for values in the columns. Familiarise yourself with the tables and the data.

Important Questions Restrictions.

A number of questions will impose which statements are allowed in the solution. They usually have to do with restricting the type of aggregate functions you are allowed to use for the solution. For example, they might specify that you are not to use the SUM function but instead sum the values using the loop operations. Please follow the restrictions closely. They are in place to make you better understand the operations and execution of the PL/SQL. You will be penalised for not following the restrictions.

Please read the questions carefully and make sure you format the output as requested.

I_CAR

I_CARGROUP

I_MODEL

I_CUSTOMER

I_BOOKING

Question 1

Write an anonymous block that places a substitution variable (&) into a local variable of type varchar2. You will need to convert the types and round them to nearest tens unit. For example 84.4555 would be 84.5. You should check the value entered in the local variable and output different messages depending on the value provided. The anonymous block is a simple grade calculator with the following rules.

If value less than 44.5 output the following message "Resulting Grade for VALUE marks is ‘F'"
If value is between 44.5 and 49.4 output the following message "Resulting Grade for VALUE marks is ‘IS'"
If value is between 49.5 and 64.4 output the following message "Resulting Grade for VALUE marks is ‘C'"
If value between 64.5 and 74.4 output the following message "Resulting Grade for VALUE marks is ‘B'"
If value is between 74.5 and 84.4 output the following message "Resulting Grade for VALUE marks is ‘A'"
If value is between 84.5 and 100 output the following message "Resulting Grade for VALUE marks is ‘HD'"
If the value does not fall in the range of 0 - 100 print an error message "ONLY MARKS BETWEEN 0 AND 100 ACCEPTED)"

Note: The ‘VALUE' in the message is to be replaced by the value of the substitution local variable value.

Single quotes are required around the grade results.

Sample run and output:

To be submitted:

Structured documented code to solve the problem listed.
Sample execution screens captures with output for following test values:
110, 44.45, 49.5, 70.07, 86.67
You will need to run your solution once for every test value and capture the resulting screen output.

Question 2

Write an anonymous block that meets the following specification:

1. Using an explicit cursor, retrieve each row from the i_car table.

2. Create a local variable that inherits the structure of the i_car table (using %ROWTYPE attribute). Place each row returned into this variable.

3. Using an implicit cursor, calculate the number of bookings that belong to each car.

4. Display the car registration, car group name, model name and the number of bookings for all the cars that have two or more bookings.

5. If the car has no bookings sum up the number of cars without bookings.

6. At the end of the run display a message "There are VALUE cars that have no bookings recorded".

Note: The VALUE is to be replaced with the total number of cars found during the process without bookings. The VALUE needs to be calculates during the explicit cursor execution.

You can only use one COUNT( ) statement for your solution in the body of the anonymous block.

To be submitted:

Structured documented code to solve the problem listed.

Screenshot of the output after executing your solution.

Question 3

Create a bound/host (or global) variable named G_NEWCOST.

Write an anonymous block that declares two local variables: A3_COST and B3_COST. The data types of these two variables should be the same as the data type of the columncost ini_car table. Also declare a constant called DEPRECIATION with value 15.25 to be used for deprecation calculation.

In your BEGIN section, write two SELECT queries to obtain value of thecost column wherecar_group_name is ‘A3' and ‘B3' and assign the corresponding values to A3_COST and B3_COST variables.
Now use the IF-THEN statement to compare the two variables to find out which one has a highest value. Calculate the new cost by using constant DEPRECIATION to calculate the new valuetotal cost * ((100 - DEPRICATION)/100) to the higher value and assign the new value to bound/host variable G_NEWCOST.
Display a message in the following format from your code block: "The car group CARGROUP has total cost of $TOTALCOST.XX and has been depreciated to $G_NEWCOST.XX"
TheCARGROUP should display the highest car group (A3 or B3 depending on values).
TheTOTALCOST will be the total calculated in the SELECT query statement.
G_NEWCOST will be the derived value after decreasing the cost with the DEPRECIATION value. Format theG_NEWCOST value to 2 decimal places.
TheXX represent the decimal places in the format.

Using the PRINT command, output the value in the host variable (G_NEWCOST) after the anonymous block has run.

To be submitted:
Structured documented code to solve the problem listed.
Output screenshot after running the code with the message as requested.
Output screenshot after executing the PRINTG_NEWCOST statement.

Question 4

Write a PL/SQL solution that displays the registration and the maximum and the minimum miles travelled by a car during the rental period for all the bookings where the booking has been paid for.
The output from the anonymous block will be two messages. One message will display the information for the maximum miles driven and one for the minimum miles driven in the following format.
"The maximum miles driven was MAXIMUM by car REGISTRATION over DAYS day's"
"The minimum miles driven was MINIMUM by car REGISTRATION over DAYS day's"
WhereMAXIMUM is the maximum miles calculated from the bookings table.
MINIMUM is the minimum miles calculated in the bookings table.
DAYS is the rental_period for the maximum and minimum miles travelled in the booking table.

Your program must use at least one explicit cursor and must NOT use any aggregate functions, for example SUM, MAX, COUNT, etc.

(Hint: miles driven for each booking will need to be calculated. Only the bookings where the booking has been paid for should be processed. All the information for the program is located in the i_booking table)

MARKING CRITERIA

1. The code produces the required output.

2. The code is appropriately structured and documented

3. The code addresses the specification.

4. The code provides a solution and covers every element in the specification.

5. The code has at least one explicit cursor

6. The code has no aggregate SQL functions.

7. The code adopts an optimal and sophisticated approach to PL/SQL.

To be submitted:

Structured documented code to solve the problem listed.

Screenshot of the output after executing your solution.

Reference no: EM13977148

Questions Cloud

Managing healthcare professionals : Thread: Choose a topic (within the last 5 years) that presents a challenge or obstacle related to managing human resources (the healthcare professional[s]) in health care. Describe the challenge or obstacle, its relevance, and present a solution (res..
You are analyzing two companies that manufacture electronic : You are analyzing two companies that manufacture electronic toys-Like Games Inc. and Our Play Inc. Like Games was launched eight years ago, whereas Our Play is a relatively new company that has been in operation for only the past two years. However, ..
Find the equation of the tangent line and normal : Find the equation of the tangent line and normal line to the curve y = (2 + 3x) ^ 2 at the point (-4,100). Write the equations of the lines in the form y = mx + b
Find out the return on an average stock : HE's stock, which has a beta coefficient equal to 1.1, is selling for $37.50 per share. Currently, the risk-free rate of return is 4 percent, and the return on an average stock is 10 percent. If HE's stock is selling at its equilibrium price, what..
Calculate the number of bookings that belong to each car. : The VALUE is to be replaced with the total number of cars found during the process without bookings. The VALUE needs to be calculates during the explicit cursor execution.
How distant in meters is the probe : The team monitoring a space probe exploring the outer solar system finds that radio transmissions from the probe take 2.38 hours to reach earth. How distant (in meters) is the probe?
What is the maximum height the ball reaches : What is the maximum height the ball reaches? What is the velocity of the ball when it hits the ground (height 0)
How much energy is dissipated by the rightmost resistor : You wait a bit and at time t = RC, you open S1 and close S2. How much energy is dissipated by the rightmost resistor (the resistor closest to S2)?
Find the maximum distance the spring is compressed : A 500-g block is released from rest and slides down a frictionless track that begins 2.00 m above the horizontal, as shown in the figure below. At the bottom of the track, where the surface is horizontal, the block strikes and sticks to a light s..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Proposed solution for converged network solution

This is an individual project. Each student must complete a Case Study that provides the requirements analysis and a proposed solution for converged network solution. The target audience will be the organization's Chief Information Officer (CIO)..

  Which information in computer critical to personal life

Let the information stored in the personal computer. Do you, at this moment, have information stored in your computer that is critical to your personal life?

  Comprised of a two-dimensional grid of cells

The farm area that is operated on during the game is comprised of a two-dimensional grid of cells, each representing a plot of land. These cells are referenced by a coordinate pair; e.g. (2, 3). This land can be used to cultivate crops or graze li..

  Design concept in terms of the usability of the design

A justification for the design concept in terms of the usability of the design. You should explain why your decisions make sense and why your interface concept works for the application. Any preliminary designs can be included as an Appendix to th..

  Question about flight function

An airline vice president in charge of operations requires to determine whether the current estimates of flight times are accurate. because there is a larger possiblity of variations due to wether and air traffic in the longer flights.

  Features frequently used in web programming

In this assignment, you will experience some of the C# features frequently used in Web programming.There isn't any client interaction in this assignment; rather,you statically construct some to-do item instances(you create a class named ToDoItem w..

  How well staff able to handle the option

Then write a debriefing report that includes the "pros" and "cons" of the four options presented to the vice president and division manager in the case study. Include a recommendation for the one of the four options you feel would be the most appr..

  Verify the correctness of the board content

The mission of this assignment is to implement a "Sudoku game board" and interact with user using a small set of commands that enable to initialize the game board. You program must permit user to see the game board, swap rows,

  Create your own function that accepts one input parameter

Using Pseudocode, create your own function that accepts one input parameter and returns a float number. You decide the theme.

  Demonstrate an ability to communicate ideas

What kind of study does the question suggest (empirical--e.g., ethnography, case study, descriptive study, experimental; historical--oral or archival or both; theoretical; discourse or textual analysis, etc.) -  What data do you need to collect

  The standard deviation for fe73 to achieve six sigma quality

The standard deviation for FE73 to achieve Six Sigma quality

  Discussing your midterm thoughts and reflections

Discussing your midterm thoughts and reflections about the course - what you have learned in the classroom when you have your own class or how do you imagine it being used, if you have a class, what do you plan on changing?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd