c# - Cannot find symbol for method -
i have never had problem before, don't know why doing this. trying call on method.calctonsco2(); giving me cannot find symbol error. know method exists , not making typos... whats going on
main method tester:
public class co2footprintv1tester { public static void main (string[] args) { //declaration of variables double gals, tons, pounds; //initialization co2footprintv1tester footprint = new co2footprintv1tester(); //methods footprint.calctonsco2(); footprint5.converttonstopoundsco2(); tons = footprint.gettonsco2(); pounds = footprint.getpoundsco2(); } }
main method class:
public class co2footprintv1 { //declaration of private instance variables private double mygallonsused; private double mytonsco2; private double mypoundsco2; /** * constructor ojbects of type co2footprintv1 * @param gals gallons used * */ co2footprintv1 (double gals) { mygallonsused = gals; } /** * method calculate tons of co2 */ public void calctonsco2() { mytonsco2 = (8.78 * math.pow(10 , -3)) * mygallonsused; } /** * method convert tons pounds */ public void converttonstopoundsco2() { mypoundsco2 = mygallonsused * 2204.62; } /** * method mytonsco2 private instance */ public double gettonsco2() { return mytonsco2; } /** * method mypoundsco2 private instance */ public double getpoundsco2() { return mypoundsco2; } }
well not sure particular programming language using calctonsco2()
method defined on co2footprintv1
class trying call on instance of co2footprintv1tester
class.
public class co2footprintv1 { ....... public void calctonsco2() { mytonsco2 = (8.78 * math.pow(10 , -3)) * mygallonsused; } .... }
you calling
co2footprintv1tester footprint = new co2footprintv1tester(); footprint.calctonsco2();
it should rather be
co2footprintv1 footprint = new co2footprintv1(); footprint.calctonsco2();
Comments
Post a Comment