Reputation: 105
im currently learning the basics of Java. I currently am having trouble finding out what symbol cannot be found by the compiler. I honestly have no idea what is wrong with my method. Any insight would be greatly appreciated.
import java.util.Scanner;
public class GasVolume {
final static double GAS_CONST = 8.3144621;
double ComputeGasVolume (double gasPressure, double gasTemperature, double
gasMoles) {
double gasVolume = ((gasMoles * GAS_CONST) * gasTemperature) / gasPressure;
return gasVolume;
}
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
double gasPressure;
double gasMoles;
double gasTemperature;
double gasVolume;
gasPressure = 100;
gasMoles = 1 ;
gasTemperature = 273;
gasVolume = computeGasVolume(gasPressure, gasTemperature, gasMoles);
System.out.println("Gas volume: " + gasVolume + " m^3");
}
}
When I compile the program, the error I get is:
GasVolume.java:23: error: cannot find symbol
gasVolume = computeGasVolume(gasPressure, gasTemperature, gasMoles);
^
symbol: method computeGasVolume(double,double,double)
location: class GasVolume
1 error
Upvotes: 0
Views: 94
Reputation: 2765
you declared your method as "ComputeGasVolume" and trying to call it as "computeGasVolume". Java is case sensitive. and certainly computeGasVolume has to have "static" in declaration as it is called from static "main" method
Upvotes: 1