• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trouble with program

 
erin topper
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



The problems I am having are: I am trying to get the SSN to have a hyphen. I am getting an error on the + sign just on the one line under the return SSN method.
I am also having trouble getting the annual salary to be a decimal. I keep getting an error using the decimal format.

Any help would be great!
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi erin topper,

Please TellTheDetails. If you take a look at those compile time errors, you will get pretty much information about how to fix those.

I've not gone through decimal code, because I found SSN code itself pretty weird. There, first thing is - you are calling a getter method, which returns a String, but you are not assigning it to anything. This is the reason for compilation error.

But the most odd part I found was - you are making a recursive call for getter method of SSN! Why is it so? You can directly access the member right? Besides, there is no exit condition, so that method is gonna blow the call stack.

Further to that, you are not doing any validation within getter/setter methods. Even if you get rid of compilation errors and remove recursive calls, you are still assuming that SSN would be always 10 digit. What if someone provides SSN of length 1 during object creation?

I hope this helps.

And Welcome to CodeRanch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic