我在java类的简介中,我们被指示创建一个天气应用程序。当我编译代码时,我得到三个错误。请记住,我们使用Git BASH编译代码,并使用sublime文本编写代码。我们不允许使用像Eclipse这样的任何IDE。
错误:
$ javac src/com/bradywemette/weatherapp/WeatherApp.java
src\com\bradywemette\weatherapp\WeatherApp.java:3: error: package com.bradywemette.converters does not exist
import com.bradywemette.converters.TemperatureConverter;
^
src\com\bradywemette\weatherapp\WeatherApp.java:10: error: cannot find symbol
TemperatureConvertor tc = new TemperatureConvertor();
^
symbol: class TemperatureConvertor
location: class WeatherApp
src\com\bradywemette\weatherapp\WeatherApp.java:10: error: cannot find symbol
TemperatureConvertor tc = new TemperatureConvertor();
^
symbol: class TemperatureConvertor
location: class WeatherApp
3 errors
WeatherApp.java代码:
package com.bradywemette.weatherapp;
import com.bradywemette.converters.TemperatureConverter;
import java.util.Scanner;
public class WeatherApp {
public static void main(String[] args){
TemperatureConvertor tc = new TemperatureConvertor();
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a temperature in celsius");
int tempCelsius = keyboard.nextInt();
float tempFahrenheit = tc.celsiusToFarhenheit((float)tempCelsius);
System.out.println(tempCelsius + " is" + tempFahrenheit + " fahrenheit");
}
}
Temperatureconverter.java代码:
package com.bradywemette.converters;
public class TemperatureConverter{
public float celsiusToFarhenheit(float celsius){
float fahrenheit = celsius * (9f/5f) + 32;
return fahrenheit;
}
}
感谢任何帮助。