I dont understand why I get 0.00 for all of the new bulb column.
Here is the calculating class.
Here is the tester.class CO2Footprint { private int numP, numL, lTotal ; private double eEmissions, gas, gasFP, aveBill, avePrice, paRed, plaRed ,gRed, cRed, eReductions, eRTotal, gWE, tRedPaper, tRedPlastic, tRedGlass, tRedCans, CO2Footprint; private boolean paper, plastic, glass, cans; public CO2Footprint( int numberOfPeople, int gasFootPrint, double averageElectricBill, double averageElectricPrice, boolean paperRecyled, boolean plasticRecyled, boolean glassRecyled, boolean cansRecyled, int numLightsRecyled) { numP = numberOfPeople; gas = gasFootPrint; aveBill = averageElectricBill; avePrice = averageElectricPrice; paper = paperRecyled; plastic = plasticRecyled; glass = glassRecyled; cans = cansRecyled; numL = numLightsRecyled; } public double calculateGasEmissions(){ gasFP = 19.3565 * gas; return gasFP; } public double calculateElectricityEmissions(){ eEmissions = (aveBill/avePrice) * 1.37 * 12; return eEmissions; } public double calcWasteReduction(){ eReductions = numL * 1.37 * 73; return eReductions; } public double calcGrossWasteEmission() { gWE = numP * 1018; return gWE; } public double calcCanReductions() { double can = 165.8; if (cans){ cRed = (can * numP); } return cRed; } public double calcGlassReductions() { double glassReduce = 46.6; if(glass){ gRed = (glassReduce * numP); } return gRed; } public double calcPlasticReductions() { double plasticReduce = 25.6; if(plastic){ plaRed = (plasticReduce * numP); } return plaRed; } public double calcPaperReductions() { double paperReduce = 184.0; if(paper){ paRed = (paperReduce * numP); } return paRed; } public double calcEmissionReductionTotals() { eRTotal = paRed + plaRed + gRed + cRed; return eRTotal; } public double calcCO2Footprint() { CO2Footprint = (gas + eEmissions + gWE) - (eRTotal + eReductions); return CO2Footprint; } }
public class CO2FootprintTester { public static void main(String[] args){ // Create an array of 5 families CO2Footprint[] fp = new CO2Footprint[5]; fp[0] = new CO2Footprint(3, 2604, 227.29, .084, true, true, true, true, 9); fp[1] = new CO2Footprint(6, 3029, 213.28, .081, false, true, false, true, 3); fp[2] = new CO2Footprint(2, 1745, 234.78, .085, true, false, true, false, 5); fp[3] = new CO2Footprint(5, 3590, 256.04, .084, false, false, false, false, 1); fp[4] = new CO2Footprint(1, 1362, 221.96, .086, true, true, true, true, 8); for(int counter = 0; counter < 5; counter++){ fp[counter].calculateGasEmissions(); fp[counter].calculateElectricityEmissions(); fp[counter].calcWasteReduction(); fp[counter].calcGrossWasteEmission(); fp[counter].calcEmissionReductionTotals(); fp[counter].calcCO2Footprint(); } //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 |"); for (int counter = 0; counter < fp.length; counter++) { System.out.printf(" %5.2f", fp[counter].calculateGasEmissions()); System.out.printf(" %5.2f", fp[counter].calculateElectricityEmissions()); System.out.printf(" %5.2f", fp[counter].calcWasteReduction()); System.out.printf(" %5.2f", fp[counter].calcGrossWasteEmission()); System.out.printf(" %5.2f", fp[counter].calcEmissionReductionTotals()); System.out.printf(" %5.2f", fp[counter].calcCO2Footprint()); System.out.print("\n"); } } }