Question
Using C# 1. Assume that you have a retail store with inventory. Once a month, you adjust pricing for items that have been in stock
Using C#
1. Assume that you have a retail store with inventory. Once a month, you adjust pricing for items that have been in stock for more than 90 days, discounting inventory items priced under $500.00 by 10 percent and higher-priced items by 20 percent. Higher-priced items have an additional profit margin.
2. Make a new console application and add System.Threading.Tasks to the using statements if it is not already listed there.
3. Define an integer array that contains pricing of items in stock more than 90 days. int[] inventoryList ={100, 750, 400, 75, 900, 975, 275, 750, 600, 125, 300};
4. In the Main method, define a Parallel.For loop to enumerate the inventory. a. Parallel.For( 0, inventoryList.Length, (index) => { // your code goes here b. Now insert your code for the parallel operation. Define a temporary variable to hold the price of the current inventory item. If the price is greater than $500.00, apply a 20 percent discount. Otherwise, use a 10 percent discount. //your code goes here c. Insert a Console.WriteLine in the function to display the adjusted price as it is calculated }
5. After the loop has completed its processing, use a normal (non-parallel) loop to display the prices as they exist in the array.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started