I'm writing a two class application with an array to store 7 days of temperatures. I need to include methods to give the highest, lowest, average, average excluding the lowest and the number of days with temperatures lower than a user inputted temp. The second class is to test the first.
I obviously haven't finished because I'm getting errors trying to calculate the average ("No overload for 'GetAverage' takes 0 arguments").
First Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace A13
{
class WeeklyTemps
{
private int[] temps;
private int average,
sum,
lowest,
highest,
highestWOLowest,
inputTemp,
range,
noOfDays;
public WeeklyTemps()
{
}
public WeeklyTemps(int [] temps)
{
}
public int GetAverage(int [] temps)
{
int sum = temps.Sum();
average = sum / temps.Length;
return average;
}
public int GetLowest()
{
lowest = temps.Min();
return lowest;
}
public int GetHighest()
{
return highest;
}
public int GetAverageWOLowest()
{
return highestWOLowest;
}
public int NoOfDays(int inputTemp)
{
return noOfDays;
}
public override string ToString()
{
string s = range.ToString();
return s;
}
}
}
Second Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
WeeklyTemps weeklyTemps1 = new WeeklyTemps(new int [] {71,72,73,74,75,76,77});
Console.WriteLine(weeklyTemps1.GetAverage());
}
}
}
Any help is appreciated.

New Topic/Question
Reply



MultiQuote






|