theralsei
theralsei
CC#
Created by theralsei on 5/27/2023 in #help
"FOR"
I have this code:
{
internal class Program
{
static void Main(string[] args)
{
int[] foodPrices = { 70, 60, 55, 30, 80, 130 };
int[] foodAmount = { 5, 10, 10, 7, 12, 15 };

Console.WriteLine("Pizzeria!");
Console.SetCursorPosition(0, 5);
Console.WriteLine("Prices:");
for (int i = 0; i < foodPrices.Length; i++)
{
Console.WriteLine($"\nPizza {i+1} cost {foodPrices[i]}." );
for(int j = 0; j < foodAmount.Length; j++)
{
Console.WriteLine($"Pizza {i+1} left {???}");
}
}
}
}
}
{
internal class Program
{
static void Main(string[] args)
{
int[] foodPrices = { 70, 60, 55, 30, 80, 130 };
int[] foodAmount = { 5, 10, 10, 7, 12, 15 };

Console.WriteLine("Pizzeria!");
Console.SetCursorPosition(0, 5);
Console.WriteLine("Prices:");
for (int i = 0; i < foodPrices.Length; i++)
{
Console.WriteLine($"\nPizza {i+1} cost {foodPrices[i]}." );
for(int j = 0; j < foodAmount.Length; j++)
{
Console.WriteLine($"Pizza {i+1} left {???}");
}
}
}
}
}
I somehow need to make it so that I was shown both the price of pizza and its amount. I ran into a problem: the whole array is shown to me, and not the value determined from it. How can I extract this particular value for each pizza?
60 replies