Extracting Methods Trouble

Hi,

I’m currently doing the Extracting Methods section of the multi-video Java series, and I’m having trouble with actually following the steps, as my mortgage calculator code ended up different from Moshes. Essentially, his had calculations going on throughout the program, while I basically left all of the calculations for the end, and my while loops a little different. I’ll upload the picture of the new method creation (cannot upload picture of original code because I’m a new user)

I’m basically running in the issue of my variables getting the error of “cannot be resolved”, “cannot be resolved to type” (the NumberFormat currency), and “duplicate local variable” (for numerator and denomiator (and yes, I realize I forgot the second n haha).

So, I actually figured it out. I realized that I had my variables declared inside of main, which was obviously not class-wide. Then, I looked at some other code and realized that it wouldn’t make sense to declare double numerator and denominator inside of the calculateMortgage method since I declared them as part of the method itself. Hopefully this can help anyone who has the same issues and stumbles upon this post!

1 Like