In the student sample program files for this chapter, you will find a text file named house_prices.csv. The file contains the following data about houses for sale in a city: Price Number of bedrooms Number of bathrooms Square feet of living space The data stored in each line is formatted in the following way: Price,Bedrooms,Bathrooms,SquareFeet Notice that the data items are separated by commas. The first line in the file looks like this: 221900,3,1,1180 The data stored in this line is: Price = $221,900 Bedrooms = 3 Bathrooms = 1 Square feet = 1,180 Design a class that has properties for the four pieces of data. In an application, read the file and store each house’s data in an instance of the class. The class instances should be stored in a List. The application should let the user search the List for the prices of houses with the number of bedrooms within a range, the number of bathrooms within a range, and the square feet of living space within a range. For example, all houses with two to four bedrooms, two to three bathrooms, and 1,500–2,500 square feet of living space. The application should display the data for each house that matches the search criteria in a ListBox. Here are some tips: Use the Split method that we discussed in Chapter 8 to tokenize each line of the file into the four pieces of data. Use the FindAll method discussed earlier in this chapter to search the List." This is a homework problem that has to deal with reading a CSV file into a ListBox. I have spent a lot of time on this with no success. Some help would be greatly appreciated.
"In the student sample program files for this chapter, you will find a text file named house_prices.csv. The file contains the following data about houses for sale in a city:
-
Price
-
Number of bedrooms
-
Number of bathrooms
-
Square feet of living space
The data stored in each line is formatted in the following way:
Price,Bedrooms,Bathrooms,SquareFeet
Notice that the data items are separated by commas. The first line in the file looks like this:
221900,3,1,1180
The data stored in this line is:
-
Price = $221,900
-
Bedrooms = 3
-
Bathrooms = 1
-
Square feet = 1,180
Design a class that has properties for the four pieces of data. In an application, read the file and store each house’s data in an instance of the class. The class instances should be stored in a List.
The application should let the user search the List for the prices of houses with the number of bedrooms within a range, the number of bathrooms within a range, and the square feet of living space within a range. For example, all houses with two to four bedrooms, two to three bathrooms, and 1,500–2,500 square feet of living space. The application should display the data for each house that matches the search criteria in a ListBox.
Here are some tips:
-
Use the Split method that we discussed in Chapter 8 to tokenize each line of the file into the four pieces of data.
-
Use the FindAll method discussed earlier in this chapter to search the List."
This is a homework problem that has to deal with reading a CSV file into a ListBox. I have spent a lot of time on this with no success. Some help would be greatly appreciated.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images