Monday 29 April 2013

An automobile company has developed an application for maintaining the number of wheels in a vehicle. Predict the output of the following code of the application: using System; class Vehicle { public int Number_of_tyres; } class MyVehicle { static void Main(string[] args) { Vehicle Motorcycle = new Vehicle(); Vehicle Car = new Vehicle(); Console.WriteLine("Enter the number of wheels in a car:"); Car.Number_of_tyres = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the number of wheels in a Motorcycle:"); Motorcycle.Number_of_tyres = Convert.ToInt32 (Console.ReadLine()); Console.WriteLine("\n"); Console.Write (Car.Number_of_tyres); Console.WriteLine(" :is the number of wheels in a Car \n"); Console.Write (Motorcycle.Number_of_tyres); Console.WriteLine(" :is the number of wheels in a Motorcycle \n"); Console.ReadLine(); } } (Duration: 25 min)

using System;
class Vehicle
{
      public int Number_of_tyres;
}
     class MyVehicle
{
    static void Main (string[] args)
 {

        Vehicle Motorcycle= new Vehicle();

        Vehicle Car = new Vehicle();

        Console.WriteLine("Enter the number of wheels in a car:");

        Car.Number_of_tyres=Covert.ToInt32(Console.ReadLine());

        Console.WriteLine("Enter the number of wheels in a Motorcycle:");

        Motorcycle.Number_of_tyres=Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n");

        Console.Write(Car.Number_of_tyres);

 Console.WriteLine(" :is the number of wheels in a Car\n");

 Console.Write(Motorcycle.Number_of_tyres);

 Console.WriteLine(" :is the number of wheels in a Motorcycle \n");
  }
}
     

1 comment:

  1. Enter the number of wheel in a car:
    4
    Enter the number of wheels in a motorcycle:
    2

    4:is the number of wheels in a car
    2:is the number of wheels in a car

    ReplyDelete