write a temperature application . Your solution should be a 2 class application
ID: 3565305 • Letter: W
Question
write a temperature application . Your solution should be a 2 class application that has a one dimensional array as a data member . The array stores temperatures for any given week . Provide constuctors for instantiating the class and methods to return the highest temperatures, lowest temperatures, average temperatures. Provide a method that accepts as an argument a temperature and returns the number of days the temperatureswere belowthat value. Override the ToString ()method to return a listing of all the temperatures in 3 column format and the temperature range for the given week. Write a second class to test your class.
Explanation / Answer
class Temperature
{
float[] weekTemp;
public Temperature()
{
weekTemp = new float[7];
}
public Temperature(float[] temp)
{
weekTemp = temp;
}
public float HighestTemp()
{
return weekTemp.Max();
}
public float LowestTemp()
{
return weekTemp.Min();
}
public float AvgTemp()
{
return weekTemp.Average();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.