Hello everyone!
Im very new to C# and I am trying to complete my assignment but I came across some errors that I don't understand how to fix or even what they are implying.
using System;
public class Assignment1B
{
public static void Main(string[] args)
{
string item_one, itemtwo;
int itemone_quantity, itemtwo_quantity;
float itemone_cost, itemtwo_cost, itemone_total, itemtwo_total;
Console.Write("What are you buying? ");
item_one = Console.ReadLine();
Console.Write("How many? ");
itemone_quantity = int.Parse(Console.ReadLine());
Console.Write("What do they cost? ");
itemone_cost = float.Parse(Console.ReadLine());
Console.WriteLine();
Console.Write("What else are you buying? ");
itemtwo = Console.ReadLine();
Console.Write("How many? ");
itemtwo_quantity = int.Parse(Console.ReadLine());
Console.Write("What do they cost? ");
itemtwo_cost = float.Parse(Console.ReadLine());
Console.WriteLine();
itemone_total = itemone_quantity * (float)itemone_cost;
itemtwo_total = itemtwo_quantity * (float)itemtwo_cost;
Console.WriteLine("Your list:");
Console.WriteLine("--------");
Console.Write(item_one, " (" + itemone_quantity + " )");
Console.Write(itemone_cost, " (" + itemone_total + " )");
Console.WriteLine();
Console.Write(itemtwo, " (" + itemtwo_quantity + " )");
Console.Write(itemtwo_cost, " (" + itemtwo_total + " )");
}
}
The assignment wants me to asks you for the name, quantity, and price of two grocery store items. Then display them as a list.
What I have tried:
I have tried looking up the error codes individually to try and see if I can find an example to get a better understanding of why I am getting the error but I havent found anything that deeply explains everything. Sorry I am still learning and I am open to any advice or tips.
I receive an error for:
item_one =
Console.ReadLine();
itemone_quantity = int.Parse(
Console.ReadLine());
itemone_cost = float.Parse(
Console.ReadLine());
Console.Write(
item_one, " (" + itemone_quantity + " )");
Console.Write(
itemone_cost, " (" + itemone_total + " )");
Console.Write(
itemtwo, " (" + itemtwo_quantity + " )");
Console.Write(
itemtwo_cost, " (" + itemtwo_total + " )");
Thank you