Hello all, I have been going at this for hours now and still can't get it.
I have created an array where the user can input 20 values, upon that the total is calculated, average, enteries less than 5.
I have the other two done, but the less than five seems to be giving me trouble right now. I have it so i can count how many values are less than 5, i just dont know how to display them seperately right now.
Any help would be greatly appreciated.
Thank you
/*
* Author:
* Purpose:
*
*/
using System;
class Prices
{
public static void Main()
{
// declaring necessary variables for the program.
double totalValues = 0;
int x;
int y;
double lessThanFive = 0;
double priceAverage = 0;
double higherThanAverage = 0;
double[] entryPrice = new double[20];
/////////// this was an attempt to try a parallel array at some point.
double[] lowLimit = new double[20];
double userInput;
int count = 0;
Console.WriteLine("In any order, enter 20 price values.");
for (int i = 0; i < entryPrice.Length; i++)
{
count += 1;
Console.Write("Enter Price {0}:", count);
entryPrice[i] = Convert.ToDouble(Console.ReadLine());
userInput = entryPrice[i];
}
{
totalValues = 0;
for (int cntt = 0; cntt < entryPrice.Length; cntt++)
totalValues += entryPrice[cntt];
priceAverage = totalValues / 20;
}
///////////making room for the next loop
{
for (y = 0; y < entryPrice.Length; y++)
if (entryPrice[y] < 5)
lessThanFive++;
}
Console.WriteLine("The sum of the values is: " + totalValues.ToString("C") + ".");
Console.WriteLine();
Console.WriteLine("List of prices less than $5.00. " + lessThanFive.ToString("C") + ".");
Console.WriteLine();
Console.WriteLine("The price average is: " + priceAverage.ToString("C") + ".");
Console.WriteLine();
Console.WriteLine("List of prices high than the average: " + higherThanAverage.ToString("C"));
Console.Read();
}
}