Я нашел код в Интернете, чтобы сделать свой собственный небольшой проект, так как я хочу изучать Java в свободное время, я нашел какой-то сломанный код и попытался исправить его сам по себе, насколько это возможно, но теперь я застрял , Ошибки я получаю это:Понимание метода Вызов
TempProg.java:53: error: cannot find symbol
Temperature tempConv = new Temperature();
^
symbol: class Temperature
location: class TempProg
TempProg.java:53: error: cannot find symbol
Temperature tempConv = new Temperature();
^
symbol: class Temperature
location: class TempProg
2 errors
import java.util.Scanner;
public class TempProg {
public double currentTemp;
public double TempF;
public double TempK;
public double newTemp;
public TempProg(double startCurrentTemp, double startTempF, double startTempK, double startnewTemp)
{
currentTemp = startCurrentTemp;
TempF = startTempF;
TempK = startTempK;
newTemp = startnewTemp;
}
private double Temperature(double currentTemp)
{
currentTemp = 100;
return currentTemp;
}
public double convertToF(double TempF, double currentTemp)
{
TempF = ((9 * currentTemp)/5) + 32;
return TempF;
}
public double convertToK(double TempK, double currentTemp)
{
TempK = currentTemp + 273;
return TempK;
}
public double updateTempC(double currentTemp)
{
newTemp = currentTemp;
return currentTemp;
}
public double getTemp()
{
return currentTemp;
}
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
Temperature tempConv = new Temperature();
int newTemp;
boolean entryValid;
final int MIN_TEMP = -273;
final int MAX_TEMP = 10000;
System.out.println("\tTemperature converter");
char selection = 'x';
while (selection != 'q') {
System.out.println("\n\tCurrent temperature in degrees C: " + tempConv.getTemp());
System.out.println("\tType f to display temperature in Fahrenheit");
System.out.println("\tType k to display temperature in Kelvin");
System.out.println("\tType c to set a new temperature");
System.out.println("\tType q to quit");
selection = scan.next().charAt(0);
switch(selection) {
case 'f':
System.out.println("\n\t" +tempConv.getTemp()+ " degrees C = "+tempConv.convertToF() +" degrees F");
break;
case 'k':
System.out.println("\n\t" +tempConv.getTemp()+ " degrees C = "+tempConv.convertToK() +" degrees K");
break;
case 'c':
entryValid=false;
while (!entryValid) {
System.out.print("\n\tPlease enter a new temperature: ");
newTemp = scan.nextInt();
if (newTemp < MIN_TEMP || newTemp > MAX_TEMP) {
System.out.println("\tPlease enter a valid temperature");
} else {
entryValid=true;
tempConv.updateTempC(newTemp);
}
}
break;
case 'q':
break;
default:
System.out.println("\n\tOption " + selection + " not understood");
}
}
}
}
возможно, его температурный метод. попробуйте изменить этот (в TempProg) на температуру (в нижнем регистре) –
Пробовал, чтобы не было успеха:/ – user3233837
Если класс температуры не в одном пакете, вам нужно импортировать класс. Попробуй это. PS: ошибка означает, что компилятор не смог найти Температурный класс. –