using System;
public class Car
{
// Properties of Car
public string Make;
public string Model;
public int Year;
// Constructor to initialize car object
public Car(string make, string model, int year)
{
Make = make;
Model = model;
Year = year;
}
// Method to Start the Car
public void Start()
{
Console.WriteLine(Make + " " + Model + " is starting.");
}
// Method to Stop the Car
public void Stop()
{
Console.WriteLine(Make + " " + Model + " is stopping.");
}
// Method to Accelerate the Car
public void Accelerate()
{
Console.WriteLine(Make + " " + Model + " is accelerating.");
}
}
class Program
{
static void Main(string[] args)
{
// --- Create first Car object with user input ---
Console.Write("Enter first car Make (e.g., Toyota): ");
string make1 = Console.ReadLine();
Console.Write("Enter first car Model (e.g., Corolla): ");
string model1 = Console.ReadLine();
Console.Write("Enter first car Year (e.g., 2021): ");
int year1 = Convert.ToInt32(Console.ReadLine());
Car car1 = new Car(make1, model1, year1);
car1.Start();
car1.Accelerate();
car1.Stop();
Console.WriteLine(); // Just for space
// --- Create second Car object with user input ---
Console.Write("Enter second car Make (e.g., Honda): ");
string make2 = Console.ReadLine();
Console.Write("Enter second car Model (e.g., Civic): ");
string model2 = Console.ReadLine();
Console.Write("Enter second car Year (e.g., 2020): ");
int year2 = Convert.ToInt32(Console.ReadLine());
Car car2 = new Car(make2, model2, year2);
car2.Start();
car2.Accelerate();
car2.Stop();
Console.ReadLine(); // Keep the console window open
}
}