Question

Write in C# Programming Language.   - count =0; - Create a 2d array "items". string[,] items...

Write in C# Programming Language.  

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

- Create a do while loop, when user enter "0", stop the loop.
- User enter item name, price, quantity, save these info and subtotal to array.
- increase "count++"

-conver price(decimal, Convert.ToDecimal() ) and quantity(int) to do mulplication 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, sutotal, total at the end.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is code:

using System;

namespace ConsoleApp // Project name
{
class Program
{
static void Main(string[] args)
{
string s;
string[,] items = new string[100, 4];
double total = 0;
int i = 0;
// read input
while (true)
{
Console.Write("Enter item name (enter 0 to quit): ");
s = Console.ReadLine();
if (s == "0")
{
break;
}
items[i, 0] = s;
Console.Write("Enter price : ");
s = Console.ReadLine();
items[i, 1] = s;
Console.Write("Enter quantity : ");
s = Console.ReadLine();
items[i, 2] = s;
double cost = Convert.ToDouble(items[i, 1]) * Convert.ToInt16(items[i, 2]);
total += cost;
items[i, 3] = cost.ToString();
i++;
}
for (int j = 0; j < i; j++)
{
Console.WriteLine("Item name : " + items[j, 0]);
Console.WriteLine("Price: " + items[j, 1]);
Console.WriteLine("Quantity : " + items[j, 2]);
Console.WriteLine("Sub Total : " + items[j, 3]);
}
Console.WriteLine("Total : " + total);
Console.ReadKey();
}
}
}

Output:

Enter item name (enter to quit apple Enter price : 25.26 Enter quantity 6 Enter item name (enter 0 to quit>: pen Enter price : 6 Enter quantity : 9 Enter item name (enter 0 to quit>: 0 Item name apple Price: 25.26 Quantity : 6 Sub Total:151.56 Item name pen Price: 6 Quantity : 9 Sub Total : 54 Total 205.56 1

Add a comment
Know the answer?
Add Answer to:
Write in C# Programming Language.   - count =0; - Create a 2d array "items". string[,] items...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write code in Java programming language. The ShoppingCart class will be composed with an array of...

    Write code in Java programming language. The ShoppingCart class will be composed with an array of Item objects. You do not need to implement the Item class for this question, only use it. Item has a getPrice() method that returns a float and a one-argument constructor that takes a float that specifies the price. The ShoppingCart class should have: Constructors: A no-argument and a single argument that takes an array of Items. Fields: • Items: an array of Item objects...

  • it must be in C programming language , Thanks in advance! [2D array] [50 pts] In...

    it must be in C programming language , Thanks in advance! [2D array] [50 pts] In this question, you will create a 2-D array with name arr that stores the first 36 non-negative numbers (0 to 35). You have to follow the following guidelines: • You cannot manually enter all 36 numbers by hand. If you do that you will get from this part. You have to use loop/loops to define that array. (15 pts] • You should be printing...

  • qbasic is the programming language Chapter 8 Do Programming Exercise 8-3 om page 414. Create a...

    qbasic is the programming language Chapter 8 Do Programming Exercise 8-3 om page 414. Create a string array to hold the months of the year. Call it anything you want to just make sure it's a string array is at the end of the name, e.g. months). Create a DATA statement that holds the month names: DATA "jan","Feb", "Mar" etc. Next you'll need a FOR loop to READ the DATA into the array, Call a SUB to get the rainfall...

  • Please use C Programming language (Not C++) 7.6 LAB*: Warm up: Online shopping cart (Part 1)...

    Please use C Programming language (Not C++) 7.6 LAB*: Warm up: Online shopping cart (Part 1) (1) Create three files to submit: • Item ToPurchase.h - Struct definition and related function declarations • Item ToPurchase.c-Related function definitions • main.c-main function Build the ItemToPurchase struct with the following specifications: • Data members (3 pts) • char itemName • int itemPrice • int itemQuantity • Related functions • MakeltemBlank0 (2 pts) Has a pointer to an item To Purchase parameter. Sets item's...

  • Q1 (2 pts) Shopping list Write a program that prompts a user for items on their...

    Q1 (2 pts) Shopping list Write a program that prompts a user for items on their shopping list and keeps prompting the user until they enter "Done" (make sure your program can stop even if the user enters "Done" with different cases, like "done"), then prints out the items in the list, line by line, and prints the total number of items on the shopping list. Output (after collecting items in the while loop) should look something like this: Apple...

  • Storing the Array: Write an application that uses an Array to store 10messages of type String....

    Storing the Array: Write an application that uses an Array to store 10messages of type String. You will store this Array with 10 messages of your choosing. For example, a message could be “I love Java the programming language!” or another message could be “I love Java the drink!” Initializing the Array: You may initialize your Array with the messages or have the user enter the messages. The choice is yours. Your Java code will contain a method called shoutOutCannedMessage()...

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • Java programming: I need to create a method that is given a 2D char array and...

    Java programming: I need to create a method that is given a 2D char array and a String that returns a part of the original 2D array. The input string will tell the method which rows from the input array need to be returned. For example, a 5x5 char array input along with a string "0 4" would return rows 1 and 5 of the input array. The String input will always be numbers divided by spaces and will not...

  • ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels...

    ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT