I have 3 arrays. One for the Item Number, One for Item Description and One for Price.
I want to be able to create a "table" out of it so it reads as:
Item Number: Description: Price:
50 Water $50
752 Carrots $.60
67 Ice $9
and etc. I tried creating methods using a foreach statement and then calling the methods. It works however it doesn't print side by side. Any ideas on how to fix this?
Here is the code `
using static System.Console;
class FoodOrder
{
static void Main()
{
//Variables used in the method
const int MENU_ASTERIKS = 42;
string description = "Description", itemNumber = "Item number", price = "Price";
string[] itemDescription = { "Cheese Frise", "Corn Dogs", "Cheeseburger", "Hamburger", "Fries", "Fountain Drink", "Philly Cheese Steak", "Tacos" };
int[] itemNumList = { 20, 23, 25, 31, 35, 38, 39, 34, };
double[] itemPrice = { 2.95, 1.95, 2.25, 3.10, 4.50, 3.65, 5.00, 2.75};
Write("\t");
for (int x = 0; x < MENU_ASTERIKS; ++x) //Creates a top border for the menu with the prices and is the start of the menu
Write("*");
WriteLine(" ");
Write("\t {0}\t{1}\t{2}", itemNumber, description, price);
DisplayItemNum(itemNumList); DisplayDescriptions(itemDescription);
}
//Method to dispay item number
private static void DisplayItemNum( params int[] itemNums)
{
WriteLine("\n");
foreach (int number in itemNums)
WriteLine("\t {0} ", number);
}
//Method to Display item Number
private static void DisplayDescriptions(params string[] desc)
{
WriteLine("\n");
foreach (string objects in desc)
WriteLine("\t\t\t{0}", objects);
}
}
`