im relatively new to trying to program in oop. i have been slowly working through this entire program learning as i go. i have gotten this class to compile.
/**
* Write a description of class CO2Footprint here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CO2Footprint
{
public int numPeople;
public double electricityEmissions;
public double gas;
public double gasFootPrint;
public double aveElecBill;
public double aveElecPrice;
public boolean paper;
public boolean plastic;
public boolean glass;
public boolean cans;
public int numLights;
public int lightsTotal;
public double paperReductions;
public double plasticReductions;
public double glassReductions;
public double canReductions;
public double emissionReductions;
public double emissionReductionTotal;
public double grossWasteEmission;
public CO2Footprint( int numberOfPeople, double gasFootPrint, double averageElectricBill,
double averageElectricPrice, boolean paperRecyled, boolean plasticRecyled, boolean glassRecyled,
boolean cansRecyled, int numLightsRecyled, double totalReductionsPaper, double totalReductionsPlastic,
double totalReductionsGlass, double totalReductionsCans, double electricityEmissions)
{
numberOfPeople = numPeople;
gasFootPrint = gas;
averageElectricBill = aveElecBill;
averageElectricPrice = aveElecPrice;
paperRecyled = paper;
plasticRecyled = plastic;
glassRecyled = glass;
cansRecyled = cans;
numLightsRecyled = numLights;
totalReductionsPaper = paperReductions;
totalReductionsPlastic = plasticReductions;
totalReductionsGlass = glassReductions;
totalReductionsCans = canReductions;
}
public double calculateGasEmissions(){
for(int counter = 0; counter <= 5; counter++){
gasFootPrint = 19.3565 * gas;
}
return gasFootPrint;
}
public double calculateElectricityEmissions(){
for(int counter = 0; counter <= 5; counter++){
electricityEmissions = (aveElecBill/aveElecPrice) * 1.37 * 12;
}
return electricityEmissions;
}
public double calcWasteReduction(){
for(int counter = 0; counter <=5; counter++){
emissionReductions = lightsTotal * 1.37 * 73;
}
return emissionReductions;
}
public double calcGrossWasteEmission() {
for(int counter = 0; counter <=5; counter++){
grossWasteEmission = numPeople * 1018;
}
return grossWasteEmission;
}
public double calcCanReductions() {
double can = 165.8;
for (int counter = 0; counter<=5; counter++){
if (cans){
canReductions = (can * numPeople);
}
}
return canReductions;
}
public double calcGlassReductions() {
double glassReduce = 46.6;
for (int counter = 0; counter<=5; counter++){
if(glass){
glassReductions = (glassReduce * numPeople);
}
}
return glassReductions;
}
public double calcPlasticReductions() {
double plasticReduce = 25.6;
for (int counter = 0; counter<=5; counter++){
if(plastic){
plasticReductions = (plasticReduce * numPeople);
}
}
return plasticReductions;
}
public double calcPaperReductions() {
double paperReduce = 184.0;
for (int counter = 0; counter<=5; counter++){
if(paper){
paperReductions = (paperReduce * numPeople);
}
}
return paperReductions;
}
public double calcEmissionReductionTotals() {
for (int counter =0; counter<=5; counter++){
emissionReductionTotal = paperReductions + plasticReductions + glassReductions + canReductions;
}
return emissionReductionTotal;
}
}
im working on this trying to get it to work but i am getting a .class expected on my constructor thing. if anyone can help it is appreciated.
/**
* Write a description of class CO2FootPrintTester here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CO2FootPrintTester
{
public static void main(String[] args){
CO2Footprint( int numberOfPeople, double gasFootPrint, double averageElectricBill,
double averageElectricPrice, boolean paperRecyled, boolean plasticRecyled, boolean glassRecyled,
boolean cansRecyled, int numLightsRecyled, double totalReductionsPaper, double totalReductionsPlastic,
double totalReductionsGlass, double totalReductionsCans, double electricityEmissions)
CO2Footprint fp0 = new CO2Footprint();
fp0.numPeople = 3;
fp0.gas = 2604;
fp0.aveElecBill = 227.29;
fp0.aveElecPrice = .084;
fp0.paper = true;
fp0.plastic = true;
fp0.glass = true;
fp0.cans true;
fp0.numLights 9;
CO2Footprint fp1 = new CO2Footprint();
fp1.numPeople = 6;
fp1.gas = 3029;
fp1.aveElecBill = 213.28;
fp1.aveElecPrice = .081;
fp1.paper = false;
fp1.plastic = true;
fp1.glass = false
fp1.cans = true;
fp1.numLights = 3;
CO2Footprint fp2 = new CO2Footprint();
fp2.numPeople = 2;
fp2.gas = 3590;
fp2.aveElecBill = 234.78;
fp2.aveElecPrice = .085;
fp2.paper = true;
fp2.plastic = false;
fp2.glass = true;
fp2.cans = false;
fp2.numLights = 5;
CO2Footprint fp3 = new CO2Footprint();
fp3.numPeople = 10;
fp3.gas = 3590;
fp3.aveElecBill = 256.04;
fp3.aveElecPrice = .084;
fp3.paper = false;
fp3.plastic = false;
fp3.glass = false;
fp3.cans = false;
fp3.numLights = 1;
CO2Footprint fp4 = new CO2Footprint();
fp4.numPeople = 1;
fp4.gas = 1362;
fp4.aveElecBill = 221.96;
fp4.aveElecPrice = .086;
fp4.paper = true;
fp4.plastic = true;
fp4.glass = true;
fp4.cans = true;
fp4.numLights = 8;
//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 |");
}
}