This needs to be written in C++ data structures and algorithms. Please Wrie comm
ID: 3841675 • Letter: T
Question
This needs to be written in C++ data structures and algorithms. Please Wrie comments explaining methods etc and also write a short algorithm before doing it. Thanks. Instructions: Build a Weather Program: Create a simple weather app. You should be able to: 1. Select from a list of U.S. cities 2. Should show the current weather for selected city (use the Yahoo Weather API https://developer.yahoo.com/weather/) 3. Should also show weather for the next 10 days 4. For each day (current and next 10 days) display the following: · The date (e.g. "Monday, ") · High temp · Low temp · Description (e.g. "Partly Cloudy") 5. Write a brief Paragraph explaining the data structures/algorithms used and description
Explanation / Answer
Many algorithms are recursive in nature. When we analyze them, we get a recurrence relation for time complexity. We get running time on an input of size n as a function of n and the running time on inputs of smaller sizes. For example in Merge Sort, to sort a given array, we divide it in two halves and recursively repeat the process for the two halves. Finally we merge the results. Time complexity of Merge Sort can be written as T(n) = 2T(n/2) + cn. There are many other algorithms like Binary Search, Tower of Hanoi, etc.
There are mainly three ways for solving recurrences.
Master Method is a direct way to get the solution. The master method works only for following type of recurrences or for recurrences that can be transformed to following type.
There are following three cases:
1. If f(n) = (nc) where c < Logba then T(n) = (nLogba)
Weather Program:
private void getWeather(string City)
{
try
{
//Get the data
wD = WeatherAPI.GetWeather(LanguageCode.en_US, City);
//Set image locations
string baseURL = "http://www.google.com";
string iconToday = baseURL + wD.iconTODAY;
string icon = baseURL + wD.icon;
string iconTOMORROW = baseURL + wD.iconTOMORROW;
string iconDAY2 = baseURL + wD.iconDAY2;
string iconDAY3 = baseURL + wD.iconDAY3;
//Set images
icnCurrent.ImageLocation = icon;
icnDay2.ImageLocation = iconDAY2;
icnDay3.ImageLocation = iconDAY3;
icnToday.ImageLocation = iconToday;
icnTomorrow.ImageLocation = iconTOMORROW;
//Current Conditions
lblCity.Text = wD.city;
lblCurrentCond.Text = wD.condition;
lblCurrentF.Text = "Temperature: " + wD.temp_f.ToString() + "°F";
lblWind.Text = wD.wind_condition;
//Day 2's Conditions
lblDay2.Text = wD.day_of_weekDAY2;
lblDay2Cond.Text = wD.conditionDAY2;
lblDay2High.Text = "High: " + wD.highDAY2.ToString() + "°F";
lblDay2Low.Text = "Low: " + wD.lowDAY2.ToString() + "°F";
//Day 3's Conditions
lblDay3.Text = wD.day_of_weekDAY3;
lblDay3Cond.Text = wD.conditionDAY3;
lblDay3High.Text = "High: " + wD.highDAY3.ToString() + "°F";
lblDay3Low.Text = "Low: " + wD.lowDAY3.ToString() + "°F";
//Today's Conditions
lblToday.Text = wD.day_of_weekTODAY;
lblTodayCond.Text = wD.conditionTODAY;
lblTodayHigh.Text = "High: " + wD.highTODAY.ToString() + "°F";
lblTodayLow.Text = "Low: " + wD.lowTODAY.ToString() + "°F";
//Tomorrow's Conditions
lblTomorrow.Text = wD.day_of_weekTOMORROW;
lblTomorrowCond.Text = wD.conditionTOMORROW;
lblTomorrowHigh.Text = "High: " + wD.highTOMORROW.ToString() + "°F";
lblTomorrowLow.Text = "Low: " + wD.lowTOMORROW.ToString() + "°F";
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.