what i am trying to do is take alot of information and use it to calculate a persons carbon footprint based on a list of things that are in the second class of my program. im trying to make everything very easy to read program wise. im doing this assignment and i got in over my head trying to get it done. im trying to work down from bigger problems to specific questions, but at this point i would greatly appreciate it if you guys could point out some of my errors that i am not catching. if anyone can help it is most def appreciated. im super lost and i have to get this done.

public class CO2Footprint
{
       CO2Footprint()
    {
    }
    
    
       
    
      public void calculateGasEmissions(int [] gas){
        double[] gasFootprint = new double[5];
        for(int counter = 0; counter <= 5; counter++){
            gasFootprint[counter] = 19.3565 * gas[counter];
                }
        }
            
      public void calculateElectricityEmissions(int [] averageElectricBill, int [] averageElecPrice){
        double[] electricityEmissions = new double[5];
        for(int counter = 0; counter <= 5; counter++){
             electricityEmissions[counter] = (averageElectricBill[counter]/averageElecPrice[counter]) * 1.37 * 12;
                }
            }


    public void calcWasteReduction(int [] lightsTotal){
        double[] emissionReductions = new double[5];
        for(int counter = 0; counter <=5; counter++){
            emissionReductions[counter] = lightsTotal[counter] * 1.37 * 73;
        }
}
    
       
       
       public void calcGrossWasteEmission(int [] numberOfPeople) {
            double[] grossWasteEmission = new double[5];
            for(int counter = 0; counter <=5; counter++){
                grossWasteEmission[counter] = numberOfPeople[counter] * 1018;
    }
    
}

       
    public void calcNetWasteReduction(boolean [] cans,boolean [] plastic,boolean [] glass,boolean [] paper, double[] grossWasteEmission,int [] numberOfPeople, int[] emissionReductions) {
           
           for (int counter = 0; counter<=5; counter++){
               if (cans[counter]){
               double canReductions = 165.8;
               grossWasteEmission[counter] -= (canReductions * numberOfPeople[counter]) - emissionReductions[counter];
                   }
                }
            
            
            for (int counter = 0; counter<=5; counter++){
           if(glass[counter]){
               double glassReductions = 46.6 ;
               grossWasteEmission[counter] -= (glassReductions * numberOfPeople[counter]) - emissionReductions[counter];
                }
            }
                
             for (int counter = 0; counter<=5; counter++){
              if(plastic[counter]){
               double plasticReductions = 25.6;
              grossWasteEmission[counter] -= (plasticReductions * numberOfPeople[counter]) - emissionReductions[counter];
                }
            }
           
            for (int counter = 0; counter<=5; counter++){
             if(paper[counter]){
               double paperReductions = 184.0;
               grossWasteEmission[counter] -= (paperReductions * numberOfPeople[counter]) - emissionReductions[counter];
                }
            }
        
        
        
        
        
        }
        
}
public class CO2FootPrintTester
{
        public static void main(String[] args){
            
             
        
        //declaration of variables 
        
       int [] numberOfPeople =  new int[5];
       numberOfPeople[0] = 3;
       numberOfPeople[1] = 6;
       numberOfPeople[2] = 2;
       numberOfPeople[3] = 10;
       numberOfPeople[4] = 1;
       
       double [] avgElecBill = new double[5];
       avgElecBill[0] = 227.29;
       avgElecBill[1] = 213.28;
       avgElecBill[2] = 234.78;
       avgElecBill[3] = 256.04;
       avgElecBill[4] = 221.96;
       
       for (int counter = 0; counter <=5; counter++){
           int totalAverageElectricBill = 0;
           totalAverageElectricBill += avgElecBill [counter];
           int  averageElectricBill  = totalAverageElectricBill / 5;
        }
           
       
       boolean [] cans = new boolean[5];
       cans[0] = true;
       cans[1] = false;
       cans[2] = true;
       cans[3] = false;
       cans[4] = true;
       
       boolean [] glass = new boolean[5];
       glass[0] = true;
       glass[1] = false;
       glass[2] = true;
       glass[3] = false;
       glass[4] = true;
       
       boolean [] plastic = new boolean[5];
       plastic[0] = true;
       plastic[1] = true;
       plastic[2] = false;
       plastic[3] = false;
       plastic[4] = true;
       
       boolean [] paper  = new boolean[5];
       paper[0] = true;
       paper[1] = false;
       paper[2] = true;
       paper[3] = false;
       paper[4] = true;
       
       int [] numLights = new int[5];
       numLights[0] = 9;
       numLights[1] = 3;
       numLights[2] = 5;
       numLights[3] = 1;
       numLights[4] = 8;
       
       for (int counter = 0; counter<=5; counter++){
           int []  lightsTotal;
           lightsTotal[counter] += numLights[counter];
        }
       
       
       int [] gas = new int[5];
       gas[0] = 2604;
       gas[1] = 3029;
       gas[2] = 1745;
       gas[3] = 3590; 
       gas[4] = 1362;
       
       for (int counter = 0; counter<=5; counter++){
           int gasTotal = 0;
           gasTotal += gas[counter];
        }
       
       double [] avgElecPrice = new double[5];
       avgElecPrice[0] =  .084;
       avgElecPrice[1] = .081;
       avgElecPrice[2] = .085;
       avgElecPrice[3] = .084; 
       avgElecPrice[4] = .086; 
       
       for (int counter = 0; counter <=5; counter++){
           int totalAverageElectricPrice = 0;
           totalAverageElectricPrice += avgElecPrice[counter];
           int averageElecPrice = 0;
           averageElecPrice = totalAverageElectricPrice / 5;
        }
       
      
         
        
        //call methods
        for (int counter = 0; counter <=4; counter ++){
            
        gasFootprint[counter] = CO2Footprint.calculateGasEmissions(gas);
        electricityEmissions[counter] = CO2Footprint.calculateElectricityEmissions(averageElectricBill, averageElecPrice);
        emissionReductions[counter] =  CO2Footprint.calcNetWasteReduction(cans,plastic,glass,paper, grossWasteEmission,numberOfPeople);
        grossWasteEmission[counter] = CO2Footprint.calcGrossWasteEmission(numberOfPeople);
    }

        
        //print results
        
        System.out.println("|               Pounds of CO2             |      Pounds of CO2         |                       |");
        System.out.println("|               Emmited from              |      Reduced from          |                       |");
        System.out.println("|   Gas   |      Electricity  |   Waste   |   Recycling  |  New Bulbs  |    CO2 Footprint      |");
    
       
    }
}

also i forgot to include that these are some of the requirements that i have to complete.

7. Create a minimum of five different objects.
8. Your CO2 footprint should account for the
following:
• annual estimate of gasoline used
• annual estimate of electricity used
• annual household waste produced
• annual household waste recycled
• replacement of incandescent bulbs
9. The constructor should include the following parameters:
• annual gasoline used
• average electricity bill and average electricity price
• number of people in home
• recycle paper, plastic, glass, or cans (Booleans)
• number of light bulbs replaced

i have been working for a while and still havent quite gotten far. i have a specific place where im stuck though.

gasFootprint = CO2Footprint.calculateGasEmissions(gas);

it says no static method can not be referenced as a static context

Because you are calling that method statically but it is not declared as a static method. To call it as you have defined it, you would need to create an object of that type and call the method on it.

That method doesn't return anything though, so trying to capture a return value from it won't get you anywhere.

Because you are calling that method statically but it is not declared as a static method. To call it as you have defined it, you would need to create an object of that type and call the method on it.

That method doesn't return anything though, so trying to capture a return value from it won't get you anywhere.

i have read your response and been working on trying to fix it for tha last hour. can you please help me out? so far i have got this for the first class.

public class CO2Footprint
{

    
    
       
    
      public double[] calculateGasEmissions(int [] gas){
        double[] gasFootprint = new double[5];
        for(int counter = 0; counter <= 5; counter++){
           gasFootprint[counter] = 19.3565 * gas[counter];

                }
                      return gasFootprint;
        }
            
      public double[] calculateElectricityEmissions(int [] averageElectricBill, int [] averageElecPrice){
        double[] electricityEmissions = new double[5];
        for(int counter = 0; counter <= 5; counter++){
             electricityEmissions[counter] = (averageElectricBill[counter]/averageElecPrice[counter]) * 1.37 * 12;
                }
                return electricityEmissions;
            }


    public double[] calcWasteReduction(int [] lightsTotal){
        double[] emissionReductions = new double[5];
        for(int counter = 0; counter <=5; counter++){
            emissionReductions[counter] = lightsTotal[counter] * 1.37 * 73;
        }
        return  emissionReductions;
}
    
       
       
       public double[] calcGrossWasteEmission(int [] numberOfPeople) {
            double[] grossWasteEmission = new double[5];
            for(int counter = 0; counter <=5; counter++){
                grossWasteEmission[counter] = numberOfPeople[counter] * 1018;
    }
        return grossWasteEmission;
    
}

       
    public double[] calcCanReductions(boolean [] cans,int [] numberOfPeople) {
           
               
        double [] canReductions = new double[5];
        double can = 165.8;
        for (int counter = 0; counter<=5; counter++){
                if (cans[counter]){
                canReductions [counter] = (can * numberOfPeople[counter]);
                   }
                   return canReductions;
                }
            }
        
            
            public double[] calcGlassReductions() {
                
               double[] glassReductions = new double[5];
               double glass = 46.6;
            for (int counter = 0; counter<=5; counter++){
                if(glass[counter]){
           glassReductions[counter] = (glasss[counter] * numberOfPeople[counter]);
                }
                return glassReductions;
            }
        }
            
             public double[] calcPlasticReductions() {   
             double [] plasticReductions = new double[5];
             double plastic = 25.6;
            
             for (int counter = 0; counter<=5; counter++){
                  if(plastic[counter]){
              plasticReductions[counter] = (plastics[counter] * numberOfPeople[counter]);
                }
                return plasticReductions;
            }
        }
            
           public double[] calcPaperReductions() {   
               double paper = 184.0;
               double [] paperReductions = new double[5];
              
            for (int counter = 0; counter<=5; counter++){
                 if(paper[counter]){
             paperReductions[counter] = (paper[counter] * numberOfPeople[counter]);
                }
                return paperReductions;
            }
        
        
        
        
        
        }
        
}

So now you can create a CO2Footprint object and call methods on it

CO2Footprint footprint = new CO2Footprint();
double[] glassReduct = footprint.calcGlassReductions();

So now you can create a CO2Footprint object and call methods on it

CO2Footprint footprint = new CO2Footprint();
double[] glassReduct = footprint.calcGlassReductions();

i hate to post all of this code, but i think it will help you help me. this is the part where i get really confused. this is really my first assignment like this. i used your advice but i still got errors. i appreciate any help.

public class CO2FootPrintTester
{
        public static void main(String[] args){
            
        CO2Footprint footprint = new CO2Footprint();
        
        //declaration of variables 
        
       int [] numberOfPeople =  new int[5];;
       numberOfPeople[0] = 3;
       numberOfPeople[1] = 6;
       numberOfPeople[2] = 2;
       numberOfPeople[3] = 10;
       numberOfPeople[4] = 1;
       
       double [] avgElecBill = new double [5];;
       avgElecBill[0] = 227.29;
       avgElecBill[1] = 213.28;
       avgElecBill[2] = 234.78;
       avgElecBill[3] = 256.04;
       avgElecBill[4] = 221.96;
       
       for (int counter = 0; counter <=5; counter++){
           int totalAverageElectricBill = 0;
           totalAverageElectricBill += avgElecBill [counter];
           int  averageElectricBill  = totalAverageElectricBill / 5;
        }
           
       
       boolean [] cans = new boolean[5];;
       cans[0] = true;
       cans[1] = false;
       cans[2] = true;
       cans[3] = false;
       cans[4] = true;
       
       boolean [] glass = new  boolean[5];;
       glass[0] = true;
       glass[1] = false;
       glass[2] = true;
       glass[3] = false;
       glass[4] = true;
       
       boolean [] plastic = new boolean[5];;
       plastic[0] = true;
       plastic[1] = true;
       plastic[2] = false;
       plastic[3] = false;
       plastic[4] = true;
       
       boolean [] paper  = new boolean[5];;
       paper[0] = true;
       paper[1] = false;
       paper[2] = true;
       paper[3] = false;
       paper[4] = true;
       
       int [] numLights = new int[5];;
       numLights[0] = 9;
       numLights[1] = 3;
       numLights[2] = 5;
       numLights[3] = 1;
       numLights[4] = 8;
       
       for (int counter = 0; counter<=5; counter++){
           int []  lightsTotal;
           lightsTotal[counter] += numLights[counter];
        }
       
       
       int [] gas = new int[5];;
       gas[0] = 2604;
       gas[1] = 3029;
       gas[2] = 1745;
       gas[3] = 3590; 
       gas[4] = 1362;
       
       for (int counter = 0; counter<=5; counter++){
           int gasTotal = 0;
           gasTotal += gas[counter];
        }
       
       double [] avgElecPrice = new double[5];
       avgElecPrice[0] =  .084;
       avgElecPrice[1] = .081;
       avgElecPrice[2] = .085;
       avgElecPrice[3] = .084; 
       avgElecPrice[4] = .086; 
       
       for (int counter = 0; counter <=5; counter++){
           int totalAverageElectricPrice = 0;
           totalAverageElectricPrice += avgElecPrice[counter];
           int averageElecPrice = 0;
           averageElecPrice = totalAverageElectricPrice / 5;
        }
       
      
         
        
        //call methods
        

        
        double[] gasFootprint = new double[5];
        gasFootprint = footprint.calcGlassReductions();(gas);
        double[] electricityEmissions = new double[5];
        electricityEmissions= CO2Footprint.calculateElectricityEmissions(averageElectricBill, averageElecPrice);
        double[] emissionReductions = new double[5];
        emissionReductions=  CO2Footprint.calcNetWasteReduction(cans,plastic,glass,paper, grossWasteEmission,numberOfPeople);
        double[] grossWasteEmission = new double[5];
        grossWasteEmission= CO2Footprint.calcGrossWasteEmission(numberOfPeople);
    

        
        //print results
        
        System.out.println("|               Pounds of CO2             |      Pounds of CO2         |                       |");
        System.out.println("|               Emmited from              |      Reduced from          |                       |");
        System.out.println("|   Gas   |      Electricity  |   Waste   |   Recycling  |  New Bulbs  |    CO2 Footprint      |");
    
       
    }
}
This article has been dead for over six months. Start a new discussion instead.