My gameon weather portion broke and you need to fix it - really. I found this, which is lots of cities and their avg weather.
Using the starter code which reads in that file as a String, create the two methods.
findWeather that takes in a city,country, ie Venezuela,Caracas and a month (ie 2 for feb) and returns the weather in Fahr.
findRandomCityCountry which might return Venezuela,Caracas
addMethod findNthCityCountry(int n) which will return the nth CityCountry in the list.
advanced people, write a method - isMatching(String cityCountry) which will see if cityCountry is also in this list
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
/**
* A Class to Practice with Strings.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CityWeather
{
String theFile;
public CityWeather() {
try {
theFile = new Scanner(new URL("https://myonlinegrades.com/apjava/activities/avgTemp.csv").openStream(), "UTF-8").useDelimiter("\\A").next();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String toString() {
return theFile;
}
public String findWeather(String cityCountry,int monthNum)
{
return null;
}
public String findRandomCityCountry() {
return null;
}
public static void main(String[] args)
{
CityWeather c=new CityWeather();
System.out.println(c);
//System.out.println(c.findWeather("South Korea,Seoul",4));
//System.out.println(c.findRandomCityCountry());
}
}