Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone please help me turn my pseudocode below into C# code? I am basically

ID: 3568947 • Letter: C

Question

Can someone please help me turn my pseudocode below into C# code? I am basically trying to track customer's purchases. I never know how many products a customer will purchase so I can not use a FOR loop. I want my customer to be able to enter in dollar amounts until they input -1 to represent that they have finished. If the individual item purchased is more than $50.00, I will give them a 10% discount on that item (not the entire purchase price). I am looking to output both the original price, discount price, and totals.

Explanation / Answer

The c# is pretty straighforward given your requirement.
I am expecting that you have a project setup , probably a Console Application, and you are hoping for a Main() function.

A simple version of it would be

static void Main(string[] args)
    {
        double[] ItemPrices = new double[99];
        int i = 0;
        int ItemCount = 0;
        double itemCost = 0.0,DiscountPrice=0.0, TotalPrice =0.0;
        Console.Write("Please enter item cost <-1 to stop> : ");
        while(itemCost!= -1 && i<100)
        {
            Console.Read(itemCost);
            ItemPrices[i] = itemCost;
            i = i + 1;
            ItemCount = ItemCount + 1;
        }
        Console.Write("The purchases made are : ");
        i = 0;
        while(i<ItemCount)
        {
            if(ItemPrices[i] >= 50)
            {
                DiscountPrice = ItemPrices[i] - (ItemPrices[i] * 0.1);
            }
            else
            {
                DiscountPrice = ItemPrices[i];
            }
            TotalPrice = TotalPrice + DiscountPrice;
            Console.WriteLine("Original Price : " + ItemPrices[i] + " Discounted Price: " + DiscountPrice + " ");
        }
       Console.WriteLine("total Cost : " + TotalPrice);
    }

When you add this function make sure the "using System " at the top of the page.The baove code should work in all project setups, nevertheless if you have any issues or dounts, feel free to contact. :)