C# - count =0; - Create a 2d array \"items\". string[,] items = new string[100, 4]; - Create a...

70.2K

Verified Solution

Question

Programming

C#

- count =0;
- Create a 2d array \"items\".
string[,] items = new string[100, 4];


- Create a do while loop, when the user enters \"0\", stop theloop.
- Users enter the item name, price, quantity, save this info andsubtotal to array.
- increase \"count++\"

-convert price(decimal, Convert.ToDecimal() ) and quantity(int)to do multiplication
for subtotal

- create a for loop (with count ) to cycle through the \"items\",display item name, price, quantity,
and subtotal.
accumulate subtotal

- Display total items, subtotal, total at the end.

Guide:

string[,] items = new string[100, 4];
int i, j, count;

/* input each array element's value */
for (i = 0; i < 100; i++) {

items[i,0] = Console.ReadLine(\"Enter Item Name: \");

if items[i,0] == \"0\"
break;
else
count++;

items[i,1] = Console.ReadLine(\"Enter Item Price: \");
items[i,2] = Console.ReadLine(\"Enter Item Quantity: \");
items[i,3] =(Convert.ToDouble(items[i,1])*Convert.ToDouble(items[i,2])).toString();

}

/* output each array element's value */
for (i = 0; i < count; i++)
{
for (j = 0; j < 4; j++) {
Console.WriteLine(items[i,j], \" \");
}
}

Answer & Explanation Solved by verified expert
3.6 Ratings (621 Votes)
Dear Student As per requirement submitted above kindly find belowsolutionHere new console application in C is created using visualstudio 2019 with name 2DArray This applicationcontains a class with name ProgramcsBelow isthe details of this classProgramcsamespaceusing Systemusing    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students