The code below is the file for the constructor method and the get methods
//Date: 3/18/2010
public class Taxpayer
{
private int socSec;
private double yearlyGross;
public Taxpayer(int taxPayer, double income)
{
socSec = taxPayer;
yearlyGross = income;
}
public int getSocSec()
{
return socSec;
}
public double getYearlyGross()
{
return yearlyGross;
}
}
Next is the code for the for loop printing of the constructor and get method in another file
//Date: 3/18/2010
public class UseTaxpayer
{
public static void main(String[] args)
{
Taxpayer[] somePayer = new Taxpayer[10];
int x;
for (x = 0; x < 10; ++x)
{
somePayer[x] = new Taxpayer(999999999, 0.0);
System.out.println("Social Security #: " + somePayer[x].getSocSec() + ", and yearly gross income: $" + somePayer[x].getYearlyGross());
}
}
}
As you can see if you run it, it prints out to
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
Social Security #: 999999999, and yearly gross income: $0.0
which is what I want it to do, my problem is taking it and manipulating it to read
Social Security #: 111111111, and yearly gross income: $10000.0
Social Security #: 222222222, and yearly gross income: $20000.0
Social Security #: 333333333, and yearly gross income: $30000.0
Social Security #: 444444444, and yearly gross income: $40000.0
Social Security #: 555555555, and yearly gross income: $50000.0
Social Security #: 666666666, and yearly gross income: $60000.0
all the way up to 999999999 and income of $100,000.
I spent 2 hours trying to do it with what I learned from the book and I can't figure it out. Someone help?