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

Write a console program for MS Visual C# 2010 that meet all the following requir

ID: 3544326 • Letter: W

Question

Write a console program for MS Visual C# 2010 that meet all the following requirements:


You should format your output to look something like the following:

Enter price 1 1.11
Enter price 2 2.22
Enter price 3 3.33
Enter price 4 4.44
Enter price 5 5.55
Enter price 6 6.66
Enter price 7 7.77
Enter price 8 8.88
Enter price 9 9.99
Enter price 10 10.10

The sum of the values entered is: $60.05

Prices less than $5.00:
$1.11 $2.22 $3.33 $4.44

Prices higher than average $6.01
$6.66 $7.77 $8.88 $9.99 $10.10

Press any key to continue . . .

Explanation / Answer

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;


namespace ConsoleApplication3

{

class Program

{

static void Main(string[] args)

{

string msg = "Enter a price: ";

decimal[] prices = new decimal[10];

decimal hlp=0;

for (int i = 0; i < 10; i++)

{

hlp = 0;

while (hlp == 0)

{

Console.Write(msg);

Decimal.TryParse(Console.ReadLine(), out hlp);

if (hlp != 0)

{

prices[i] = hlp;

}

}

}

for (int i = 0; i < 10; i++)

{

Console.WriteLine("Array[{0}]: {1}", i, prices[i]);

}

Console.Write("Values less than $5: ");

for (int i = 0; i < 10; i++)

{

if (prices[i] < 5)

Console.Write(prices[i] + "; ");

}

Console.WriteLine();

decimal sum = 0;

decimal avg = 0;

for (int i = 0; i < 10; i++)

sum += prices[i];

avg = (decimal)sum/10;

Console.WriteLine("The avarage is: " + avg);

Console.Write("Values higher than the avarage: ");

for (int i = 0; i < 10; i++)

{

if (prices[i] > avg)

{

Console.Write(prices[i] + "; ");

}

}

Console.WriteLine();

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote