You have been contracted by the local meteorologist to design an application tha
ID: 3783339 • Letter: Y
Question
You have been contracted by the local meteorologist to design an application that can be used to determine and display the average and high wind speeds for a given day. The wind speed is measured at 8 a.m., 12 noon and 5 p.m. every day during the week. Place the following data in a text file and use it for testing. The first value retrieved from the file is the day number (where Monday = 1, Tuesday = 2; Wednesday = 3: Thursday = 4; Friday = 5). The second, third and fourth values are the wind speed at a given time. The second value is the wind speed at 8:00 a.m., the third value is the wind speed at noon and the fourth value is the wind speed at 5 p.m. Your application should be able to provide the following methods: DetermineAverageWindSpeed() Returns the average wind speed for the given day DetermineHighestWindSpeed () Returns the highest wind speed value for the given day DisplayAIIResults() Returns details about the given day as shown below. For maximum credit: Create a multi-class solution, one that handles the business logic and a separate that test the class. The second class can be a Windows or Console app. Create an array to store the day names (Monday, Tuesday.. ..Friday) Create an array to store the time of day (8:00, Noon, 5:00) Retrieve the data from the text file and store wind speed in an array Include exception handling techniques Have extra time....for extra credit: Store one day s worth of data on a single line in your file Place multiple days' worth of data in the fileExplanation / Answer
Created a cOnsole Application for the above program .
Please Go throught he steps -
1)created Daily_Measures.txt file in Working folder with the data given in asignment.
2) Main Application
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace WindCalculationApplication_25012017
{
public class Program
{
public static string day = string.Empty;
public static string TimeSlot1 = string.Empty;
public static string TimeSlot2 = string.Empty;
public static string TimeSlot3 = string.Empty;
public static string[] WindFileData;
public static string[] DayName = new string[] { "Monday", "Tuesday", "Wendsday", "Thursday", "Friday", "Saturday", "Sunday" };
public static string[] TimeSlots = new string[] { "8:00", "Noon", "5:00" };
public static string SpecificDay = string.Empty;
static void Main(string[] args)
{
ReadIniFile();
DeterminAvgWindSpeed d = new DeterminAvgWindSpeed();
double result = d.AvgWindSpeed(Convert.ToDouble(TimeSlot1), Convert.ToDouble(TimeSlot2), Convert.ToDouble(TimeSlot3));
DeterminHighWindSpeed f = new DeterminHighWindSpeed();
double result1 = f.HighWindSpeed(Convert.ToDouble(TimeSlot1), Convert.ToDouble(TimeSlot2), Convert.ToDouble(TimeSlot3));
DisplayAllResults(result, result1);
}
public static void DisplayAllResults(double result1,double result2)
{
Console.WriteLine("Day " + TimeSlots[0].ToString() + " " + TimeSlots[1].ToString() + " " + TimeSlots[2].ToString() + " " + "Avg" + " " + "Highest");
switch (day)
{
case "1": SpecificDay = DayName[0].ToString();
break;
case "2": SpecificDay = DayName[1].ToString();
break;
case "3": SpecificDay = DayName[2].ToString();
break;
case "4": SpecificDay = DayName[3].ToString();
break;
case "5": SpecificDay = DayName[4].ToString();
break;
case "6": SpecificDay = DayName[5].ToString();
break;
case "7": SpecificDay = DayName[6].ToString();
break;
}
Console.WriteLine(SpecificDay + " " + TimeSlot1 + " " + TimeSlot2 + " " + TimeSlot3 + " " + Math.Round(result1,2) + " " + result2);
Thread.Sleep(5000);
}
public static void ReadIniFile()
{
try
{
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\Daily_Measures.txt"))
{
return;
}
else
{
WindFileData = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "\Daily_Measures.txt");
day = WindFileData[0].ToString();
TimeSlot1 = WindFileData[1].ToString();
TimeSlot2 = WindFileData[2].ToString();
TimeSlot3 = WindFileData[3].ToString();
}
}
catch (Exception ex)
{
return;
}
}
}
}
3) Class DeterminAvgWindSpeed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindCalculationApplication_25012017
{
public class DeterminAvgWindSpeed
{
public double AvgWindSpeed(double value1,double value2,double value3 )
{
double Avg = (value1 + value2 + value3) / 3;
return Avg;
}
}
}
4) class DeterminHighWindSpeed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindCalculationApplication_25012017
{
public class DeterminHighWindSpeed
{
public double HighWindSpeed(double value1, double value2, double value3)
{
return Math.Max(Math.Max(value1, value2), value3);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.