Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This code doesn't work would you please help correct it its in C# language string filename = C:/Users/deept/source/repos/WeatherFinderIncsharp/WeatherFinderIncsharp/weather.txt; //If file found read data 1/Save into

image text in transcribedimage text in transcribed

This code doesn't work would you please help correct it its in C# language

string filename = "C:/Users/deept/source/repos/WeatherFinderIncsharp/WeatherFinderIncsharp/weather.txt"; //If file found read data 1/Save into list if (File. Exists(filename)) // Read a text file line by line. string[] lines = File. ReadAlllines(filename); foreach (string line in lines) weather w; string[] temp = Regex.Split(line, ";"); w.date = temp[@]; w.precipitation = Double.Parse(temp[1]); w.maxTemp = int.Parse(temp[2]); w.mintemp = int.Parse(temp[3]); weathers.Add(w); // select a date from date time picker //Then click on button will shoqw the details of weather on 1/that particular date 1 reference private void btnWeather_Click(object sender, EventArgs e) string date = myDatePicker.value. ToString("M'/'d/yyyy"); foreach (weather win weathers) if (w.date. CompareTo(date) == 0) MessageBox.Show("Date: " + w.date + " Precipitation: + w.precipitation. ToString("#.##) + " High Temperature: " + w.maxTemp.ToString() + " Low Temperature: "+w.minTemp.ToString(); break; 3AO + + 5 //weather structure 4 references struct weather public string date; public double precipitation; public int maxTemp; public int minTemp; public partial class Form1 : Form //List for weather storage private Listcweather Weathers = new Listcweather>(); 1 reference public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) //Format Exception the date on the date time picker as our requirement myDatePicker.Format = DateTimePickerFormat.Custom; myDatePicker.CustomFormat = "M/d/yyyy"; //file name string filename = "C:/Users/deept/source/repos/WeatherFinderInCSharp/WeatherFinderIncsharp/weather.txt"; I/If file found read data //Save into list if (File. Exists(filename)) // Read a text file line by line. string[] lines = File. ReadAllLines (filename); foreach (string line in lines)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions