• 1405/05/03

تمرین آزاد از حلقه for :

سلام استاد وقتتون بخیر باشه... خدا قوت

تمرین آزاد از حلقه for

 


try
{
   Console.ForegroundColor = ConsoleColor.Magenta;

   Console.WriteLine("Please Enter The Number of Vehicles : ");

   string input = Console.ReadLine();

   int numberCar = Convert.ToInt32(input);
   Console.ResetColor();

   string[] nameCars = new string[numberCar];
   int[] modelCars = new int[numberCar];
   int[] priceCars = new int[numberCar];

   Console.ForegroundColor = ConsoleColor.Yellow;
   for (int a = 0; a < numberCar; a++)
   {
       Console.WriteLine($"Please Enter The Cars Name {a + 1} : ");
       nameCars[a] = Console.ReadLine();

       Console.WriteLine($"Please Enter The Model Car {a + 1}: ");
       modelCars[a] = Convert.ToInt32(Console.ReadLine());

       Console.WriteLine($"Please Enter The Price Car {a + 1}: ");
       priceCars[a] = Convert.ToInt32(Console.ReadLine());
   }
   Console.ResetColor();

   Console.ForegroundColor = ConsoleColor.Green;
   Console.WriteLine("************************************************");
   Console.WriteLine("Vehicle Information :");
   Console.WriteLine("************************************************");
   Console.ResetColor();

   Console.ForegroundColor = ConsoleColor.Cyan;

   for (int a = 0; a <numberCar; a++)
   {
       Console.WriteLine($"Car Name {a + 1} : '{nameCars[a]}'");
       Console.WriteLine($"Model Car {a + 1} : '{modelCars[a]}'");
       Console.WriteLine($"Price Car {a + 1} : '{priceCars[a]} Toman'");

   }
   Console.ResetColor();
}
catch
{
   Console.ForegroundColor= ConsoleColor.Red;
   Console.WriteLine("Please Enter Just Number only !");
   Console.ResetColor();
}

 

 

 

  • 1405/05/04
  • ساعت 00:51

سلام

بسیار عالی بود ، آفرین