Untitled

Task 1: Visit the below link and complete the pretest, simulation and posttest tabs:http://vlabs.iitb.ac.in/vlabs-dev/labs/oops/lab s/exp6/index.php Task 2:

  1. We want to store the information of different vehicles. Create a class named Vehicle with two data member named mileage and price. Create its two subclasses ○ Car with data members to store ownership cost, warranty (by years), seating capacity and fuel type (diesel or petrol). ○ Bike with data members to store the number of cylinders, number of gears, cooling type(air, liquid or oil), wheel type(alloys or spokes) and fuel tank size(in inches) ○ Make another two subclasses Audi and Ford of Car, each having a data member to store the model type. Next, make two subclasses Bajaj and TVS, each having a data member to store the make-type. ○ Now, store and print the information of an Audi and a Ford car (i.e. model type, ownership cost, warranty, seating capacity, fuel type, mileage and price.) Do the same for a Bajaj and a TVS bike.
#include <iostream>
using namespace std;
class Vehicle
{
public:
    float mileage, price;
};
class Car : public Vehicle
{
public:
    float own_cost;
    int warranty, seating;
    string fuel;
};
class Bike : public Vehicle
{
public:
    int num_cylinder, num_gears;
    string cool_type, wheel_type;
    float tank_size;
};
class Audi : public Car
{
public:
    string model_type;
    Audi(string model_type1, float mileage1, float price1, float own_cost1, int warranty1, int seating1, string fuel1)
    {
        model_type = model_type1;
        mileage = mileage1;
        price = price1;
        own_cost = own_cost1;
        warranty = warranty1;
        seating = seating1;
        fuel = fuel1;
    }
    void display()
    {
        cout << "\\nModel Type: " << model_type << endl
             << "Mileage:" << mileage << endl
             << "Price: " << price << endl
             << "Ownership Cost: " << own_cost << endl
             << "Warranty (in years): " << warranty << endl
             << "Seating Capacity: " << seating << endl
             << "Fuel Type: " << fuel << endl;
    }
};
class Ford : public Car
{
public:
    string model_type;
    Ford(string model_type1, float mileage1, float price1, float own_cost1, int warranty1, int seating1, string fuel1)
    {
        model_type = model_type1;
        mileage = mileage1;
        price = price1;
        own_cost = own_cost1;
        warranty = warranty1;
        seating = seating1;
        fuel = fuel1;
    }
    void display()
    {
        cout << "\\nModel Type: " << model_type << endl
             << "Mileage: " << mileage << endl
             << "Price: " << price << endl
             << "Ownership Cost: " << own_cost << endl
             << "Warranty (in years): " << warranty << endl
             << "Seating Capacity: " << seating << endl
             << "Fuel Type: " << fuel << endl;
    }
};
class Bajaj : public Bike
{
public:
    string make_type;
    Bajaj(string make_type1, float mileage1, float price1, int num_cylinder1, int num_gears1, string cool_type1, string wheel_type1,
          float tank_size1)
    {
        make_type = make_type1;
        mileage = mileage1;
        price = price1;
        num_cylinder = num_cylinder1;
        num_gears = num_gears1;
        cool_type = cool_type1;
        wheel_type = wheel_type1;
        tank_size = tank_size1;
    }
    void display()
    {
        cout << "\\nMake Type: " << make_type << "\\nMileage: " << mileage << "\\nPrice: " << price << "\\nNumber of cylinders: " << num_cylinder << "\\nNumber of gears: " << num_gears << "\\nCooling type: " << cool_type << "\\nWheel Type: " << wheel_type << "\\nTank size (in inches): " << tank_size << endl;
    }
};
class TVS : public Bike
{
public:
    string make_type;
    TVS(string make_type1, float mileage1, float price1, int num_cylinder1, int num_gears1, string cool_type1, string wheel_type1,
        float tank_size1)
    {
        make_type = make_type1;
        mileage = mileage1;
        price = price1;
        num_cylinder = num_cylinder1;
        num_gears = num_gears1;
        cool_type = cool_type1;
        wheel_type = wheel_type1;
        tank_size = tank_size1;
    }
    void display()
    {
        cout << "\\nMake Type: " << make_type << "\\nMileage: " << mileage << "\\nPrice: " << price << "\\nNumber of cylinders: " << num_cylinder << "\\nNumber of gears: " << num_gears << "\\nCooling type: " << cool_type << "\\nWheel Type: " << wheel_type << "\\nTank size (in inches): " << tank_size << endl;
    }
};
int main()
{
    Ford EcoSport("Ecosport 2012", 12.1, 1500000, 35000, 3, 7, "Diesel");
    Audi A3("A3", 6.0, 2600000, 51000, 5, 4, "Petrol");
    Bajaj Cruiser("Cruiser", 24.3, 64000, 2, 6, "liquid", "spokes", 5.2);
    TVS Commuter("Commuter", 31.5, 45000, 1, 4, "oil", "alloy", 2.5);
    EcoSport.display();
    A3.display();
    Cruiser.display();
    Commuter.display();
}

Untitled

  1. All the banks operating in India are controlled by RBI. RBI has set a well defined guideline (e.g. minimum interest rate, minimum balance allowed, maximum withdrawal limit etc) which all banks must follow. For example, suppose RBI has set minimum interest rate applicable to a saving bank account to be 4% annually; however, banks are free to use 4% interest rate or to set any rates above it. Write a program to implement bank functionality in the above scenario. Note: Create few classes namely Customer, Account, RBI (Base Class) and few derived classes (SBI, ICICI, PNB etc). Assume and implement required member variables and functions in each class. Hint: Class Customer { //Personal Details ... // Few functions ... } Class Account { // Account Detail ... // Few functions ... } Class RBI { Customer c; //hasA relationship Account a; //hasA relationship .. Public double GetInterestRate() { } Public double GetWithdrawalLimit() { } } Class SBI: public RBI { //Use RBI functionality or define own functionality. } Class ICICI: public RBI { //Use RBI functionality or define own functionality. }
#include <iostream>
using namespace std;
class customer
{
public:
    string name;
    int age;
    customer()
    {
        cout << "Enter the name: ";
        cin >> name;
        cout << "Enter the age: ";
        cin >> age;
    }
    void printInfo()
    {
        cout << "Name: " << name;
        cout << "Age: " << age;
    }
};
class account
{
public:
    int account_number, balance, interest_rate, withdrawal_limit;
    account()
    {
        cout << "Enter the account number: ";
        cin >> account_number;
        cout << "Enter the balance amount: ";
        cin >> balance;
        cout << "Enter the interest rate: ";
        cin >> interest_rate;
        cout << "Enter the withdrawal limit: ";
        cin >> withdrawal_limit;
    }
};
class RBI
{
    customer c;
    account a;
    int min_interest = 4, min_withdrawal = 1000;

public:
    void check_rates()
    {
        if ((a.interest_rate < min_interest) || (a.withdrawal_limit < min_withdrawal))
        {
            cout << "The Rates and Limits do not match the RBI standards." << endl;
        }
        else
        {
            cout << "The Rates and Limits are justified." << endl;
        }
    }
};
class SBI : public RBI
{
};
class ICICI : public RBI
{
};
int main()
{
    cout << "Enter SBI account details: " << endl;
    SBI a1;
    cout << "Enter ICICI account details: " << endl;
    ICICI a2;
    cout << "\\n\\n";
    cout << "Checking rates of SBI account..." << endl;
    a1.check_rates();
    cout << "Checking rates of ICICI account..." << endl;
    a2.check_rates();
}

Untitled

Task 3: Suppose, we have a class A which is the base class and we have a class B which is derived from class A and we have a class C which is derived from class B, we can access the functions of both class A and class B by creating an object for class C. Hence, this mechanism is called multi-level inheritance. (B inherits A and C inherits B.) Create a class called Equilateral which inherits from Isosceles and should have a function such that the output is as given below. Sample Output I am an equilateral triangle I am an isosceles triangle I am a triangle

#include <iostream>
using namespace std;
class triangle
{
public:
    string s1 = "I am a triangle";
};
class isosceles : public triangle
{
public:
    string s2 = "I am an isosceles triangle";
};
class equilateral : public isosceles
{
public:
    string s3 = "I am an equilateral triangle";
    void printall() { cout << s3 << endl
                           << s2 << endl
                           << s1; }
};
int main()
{
    equilateral e1;
    e1.printall();
}

Untitled