im working with a two class program. i have one for calculations and the other for the main method like so:
/**
* Write a description of class CO2FromWaste here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CO2FromWaste
{
private int numberOfPeople;
private int numPeople;
private double grossWasteEmission;
private boolean paper;
private boolean paperRecycled;
private boolean plasticRecycled;
private boolean plastic;
private boolean glassRecycled;
private boolean glass;
private boolean cansRecycled;
private boolean cans;
private double canReductions;
private double glassReductions;
private double plasticReductions;
private double paperReductions;
private double netWasteReduction;
private double total;
public CO2FromWaste(int numPeople, boolean paper, boolean plastic, boolean glass, boolean cans)
{
numPeople = numberOfPeople;
paper = paperRecycled;
plastic = plasticRecycled;
glass = glassRecycled;
cans = cansRecycled;
}
public double calcGrossWasteEmission(){
grossWasteEmission = numPeople * 1018;
return grossWasteEmission;
}
public double calcCanReductions() {
double can = 165.8;
if (cans){
canReductions = (can * numPeople);
}
return canReductions;
}
public double calcGlassReductions() {
double glassReduce = 46.6;
if(glass){
glassReductions = (glassReduce * numPeople);
}
return glassReductions;
}
public double calcPlasticReductions() {
double plasticReduce = 25.6;
if(plastic){
plasticReductions = (plasticReduce * numPeople);
}
return plasticReductions;
}
public double calcPaperReductions() {
double paperReduce = 184.0;
if(paper){
paperReductions = (paperReduce * numPeople);
}
return paperReductions;
}
public double calcNetWasteReduction(){
netWasteReduction = paperReductions + plasticReductions + glassReductions + canReductions;
return netWasteReduction;
}
public double total(){
total = grossWasteEmission - netWasteReduction;
return total;
}
}
/**
* Write a description of class CO2FromWasteTester here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.*;
public class CO2FromWasteTester
{
public static void main(String[] args){
List<CO2FromWaste> CO2FromWaste = new ArrayList<CO2FromWaste>();
CO2FromWaste.add(new CO2FromWaste(1, true, true, true, true));
CO2FromWaste.add(new CO2FromWaste(3, true, false, true, true));
CO2FromWaste.add(new CO2FromWaste(4, false, false, false, false));
CO2FromWaste.add(new CO2FromWaste(1, true, true, true, true));
CO2FromWaste.add(new CO2FromWaste(1, true, true, true, true));
CO2FromWaste dataRecord;
for(int index = 0; index < CO2FromWaste.size(); index++)
{
dataRecord = CO2FromWaste.get(index);
dataRecord.calcGrossWasteEmission();
dataRecord.calcNetWasteReduction();
dataRecord.total();
}
//print header
System.out.println(" Pounds of CO2");
System.out.println(" Household Waste Recycled Total Net");
System.out.println(" Index People Paper Plastic Glass Cans Emissions Reduction Emissions");
for (int counter = 0; counter < CO2FromWaste.size(); counter++) {
dataRecord = CO2FromWaste.get(counter);
System.out.printf("%4.2f", dataRecord.calcGrossWasteEmission());
System.out.printf("%4.2f", dataRecord.calcNetWasteReduction());
System.out.printf("%4.2f", dataRecord.total());
}
}
}
i have almost everything except for the output working correctly. i have no idea how to get everything to output. i have my header, but i need it to be like be like
Index People Paper Plastic Glass Cans Emissions Reduction Emissions
under each thing like paper, plastic, glass, cans i output whether each thing is true or false. i have a picture of basically what i am trying to do. i attached it.