Advertisement
hnyrenhjm5678

Untitled

Jan 29th, 2025
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         string[] productNames = new string[100];
  8.         int[] productQuantities = new int[100];
  9.         int productCount = 0;
  10.  
  11.         while (true)
  12.         {
  13.             Console.WriteLine("1. Покажи всички продукти");
  14.             Console.WriteLine("2. Създай нов продукт");
  15.             Console.WriteLine("3. Редактирай продукт");
  16.             Console.Write("Изберете опция: ");
  17.             string choice = Console.ReadLine();
  18.  
  19.             if (choice == "1")
  20.             {
  21.                 for (int i = 0; i < productCount; i++)
  22.                 {
  23.                     Console.WriteLine($"{i + 1}. {productNames[i]} - {productQuantities[i]} бр.");
  24.                 }
  25.             }
  26.             else if (choice == "2")
  27.             {
  28.                 Console.Write("Въведете име на продукта: ");
  29.                 string name = Console.ReadLine();
  30.                 Console.Write("Въведете количество: ");
  31.                 int quantity = int.Parse(Console.ReadLine());
  32.                 productNames[productCount] = name;
  33.                 productQuantities[productCount] = quantity;
  34.                 productCount++;
  35.             }
  36.             else if (choice == "3")
  37.             {
  38.                 Console.Write("Въведете номер на продукта за редакция: ");
  39.                 int index = int.Parse(Console.ReadLine()) - 1;
  40.                 if (index >= 0 && index < productCount)
  41.                 {
  42.                     Console.Write("Ново име на продукта: ");
  43.                     productNames[index] = Console.ReadLine();
  44.                     Console.Write("Ново количество: ");
  45.                     productQuantities[index] = int.Parse(Console.ReadLine());
  46.                 }
  47.             }
  48.         }
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement