using System;
public class Vehicle
{
public string model;
public int year;
public char fuelType; // P = Petrol, O = Octane, G = Gas
public void CalculateFuelEfficiency()
{
[Link]($"Enter distance traveled for {model} (km or miles): ");
double distance = [Link]([Link]());
[Link]($"Enter fuel used for {model} (liters or gallons): ");
double fuel = [Link]([Link]());
if (fuel > 0)
{
double efficiency = distance / fuel;
[Link]($"{model} Fuel Efficiency: {efficiency} km/l or
mpg");
}
else
{
[Link]("Fuel used must be greater than zero.");
}
}
}
public class Truck : Vehicle
{
public Truck()
{
model = "HeavyR1";
year = 2025;
fuelType = 'P'; // Petrol
}
}
public class Car : Vehicle
{
public Car()
{
model = "BMWZ4";
year = 2025;
fuelType = 'G'; // Gas
}
}
public class Motorcycle : Vehicle
{
public Motorcycle(string model,int year,char fuelType)
{
model = model;
year = year;
fuelType = fuelType;
}
}
class Program
{
static void Main()
{
Truck truck = new Truck();
Car car = new Car();
Motorcycle motorcycle = new Motorcycle("ABc",2024,'A');
[Link]();
[Link]();
[Link]();
}
}