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

This is for C#! I need help Writing a temperature application. The solution shou

ID: 3678573 • Letter: T

Question

This is for C#!

I need help Writing a temperature application. The solution should be a two class application that has a one-dimensional array as a data member. The array stores temperatures for any given week. Provide constructors for instantiating the class and methods to return the highest temperature, lowest temperature, average temperature, and the average temperature excluding the lowest temperature. Provide a method that accepts an argument a temperature and returns the number of days the temperatures were below that value. Override the ToString(0 method to return a listing of all the temperatures in three column format and the temperature range for the given week.

Please Write a second class to test all the methods in your Temperature class.

Explanation / Answer

ANy queries please comment


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Temp
{
class Temperatures
{
private double[] weeksTemperatures;
private double threshTemp;
public double[] WeeksTemperatures
{
set
{
weeksTemperatures = value;
}
get
{
return weeksTemperatures;
}
}
public double ThreshTemp
{
set
{
threshTemp = value;
}
get
{
return threshTemp;
}
}
public double Average
{
get
{
return GetAverage();
}
}
public double AverageExcludingLowest
{
get
{
return GetAverageExcludingLowest();
}
}
public double Highest
{
get
{
return GetHighest();
}
}
public double Lowest
{
get
{
return GetLowest();
}
}
public int NumberOfThreshs
{
get
{
return GetNumberOfThreshs();
}
}
public Temperatures()
{
}
public Temperatures(double[] wTemperatures, double threshT)
{
weeksTemperatures = wTemperatures;
threshTemp = threshT;
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("______________________________");
sb.AppendLine("Weekly Temperature statistics");
sb.AppendLine("______________________________");
sb.AppendLine("Average Temperature: " + Average.ToString());
sb.AppendLine("Highest Temperature: " + Highest.ToString());
sb.AppendLine("Lowest Temperature: " + Lowest.ToString());
sb.AppendLine("Avg. Excl. Lowest: " + AverageExcludingLowest.ToString());
sb.AppendLine("# of Cold Days: " + NumberOfThreshs.ToString());
sb.AppendLine("_______________________________");
return sb.ToString();
}
public double GetAverage()
{
var r = from temp in weeksTemperatures
select temp;
return r.Average();
}
private double GetAverageExcludingLowest()
{
var r = from temp in weeksTemperatures
select temp;
return (r.Sum() - Lowest) / r.Count();
}
private double GetHighest()
{
var r = from temp in weeksTemperatures
select temp;
return r.Max();
}
private double GetLowest()
{
var r = from temp in weeksTemperatures
select temp;
return r.Min();
}
private int GetNumberOfThreshs()
{
var r = from temp in weeksTemperatures
where temp > Lowest
select temp;
return r.Count();
}
}
}

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