JAVA
n00b here. I'm not very good at Java. In fact I am really struggling with it. I've spent the last 6 hours trying to get this to work. The book I have isn’t very helpful.
I'm supposed to create a class names Taxpayer. Data fields for Taxpayer include Social Security number (use an int for the type, and do not use dashes within the Social Security number) and yearly gross income. Methods include a constructor that requires values for both data fields, and two methods that each return one of the data fields values. Write an application named UseTaxpayer that declares an array of 10 Taxpayer objects. Set each Social Security number to 999999999 and each gross income to zero. Display the 10 Taxpayer objects.
Save the files as Taxpayer.java and UseTaxpayer.
here is the code I have written so far. I seem to have hit a wall. I'm not even sure if I went the correct course. Any suggestions?
thanks
Expand|Select|Wrap|Line Numbers
- public class Taxpayer
- {
- private int socNum;
- private double yearIncome;
- public Taxpayer(int s, int i)
- {
- socNum = s;
- yearIncome = i;
- }
- public int getSocNum()
- {
- return socNum;
- }
- public double getYearIncome()
- {
- return yearIncome;
- }
- }
Expand|Select|Wrap|Line Numbers
- public class UseTaxpayer
- {
- public static void main(String[] args)
- {
- Taxpayer[] aTaxpayer = new Taxpayer[10];
- }
- }