WAP to show rethrowing concept in oop by using suitable.
WAP to show multiple throw statement execution by using suitable example.
WAP to show exception using try throw and catch block.
WAP to show the working of abstract class by considering suitable example.
WAP to show the working of abstract class by considering suitable example
(Pure Virtual Function) Write the above program by modifying by making display() as pure virtual
function.
Q1:Define a class ABC. Derive two classes BBC and KBC from ABC. All the classes contains same
member function name as display(). The base class pointer always holds the derived class objects.
a) Write a program such that base class pointer or reference will always access/call the base version
of the members available in derived class, do not have any access to the derived class members.
b) Write a program such that base class pointer or reference will always access/call the derived
version of the members available in derived class, do not have any access to the base class
members.
Define a class ABC. Derive two classes BBC and KBC from ABC. All the classes contains same member function name as display(). The base class pointer always holds the derived class objects.
You are required to confirm the equation by a
simulation. In this simulation, you will consider how the ball moves
in very short time interval Δt.
I. You will assume that Δt is a constant double with a
value of 0.01. You can get the updated position using s = s + v * Δt. The velocity changes constantly—in
fact, it is reduced by the gravitational force of the earth. In a short time interval, Δv = –gΔt, you must
keep the velocity updated as v = v - g * Δt; In the next iteration, the new velocity is used to update the
distance.
You need to run the simulation until the cannon ball falls back to the ground. Your program should take
the initial velocity as an input. Update the position and velocity 100 times per second, but print out the
position only every full second. Also, printout the values from the exact formula s = vi t – (1/2) gt2
for the
comparison. Lastly plot the path that cannon ball will take to get the bonus marks.
Write a program that calculates the occupancy rate for a hotel. The program should start by asking the
user how many floors the hotel has. A for loop should then iterate once for each floor. In each iteration,
the loop should ask the user for the number of rooms on the floor and how many of them are occupied.
After all the iterations, the program should display how many rooms the hotel has, how many of them
are occupied, how many are unoccupied, and the percentage of rooms that are occupied. The
percentage may be calculated by dividing the number of rooms occupied by the number of rooms.
Input Validation: Do not accept a value less than 1 for the number of floors. Do not accept a number
less than 10 for the number of rooms on a floor.