@@ -9,7 +9,8 @@ public class Integers {
99 private static final BigDecimal ZERO = new BigDecimal (0 );
1010 private static final BigDecimal TWO = new BigDecimal (2 );
1111
12- public static final String toBinaryUsingDivideAndModulus (int integer ) {
12+ public static final String toBinaryUsingDivideAndModulus (int numberToConvert ) {
13+ int integer = numberToConvert ;
1314 if (integer <0 ) throw new IllegalArgumentException ("Method argument cannot be negative. number=" +integer );
1415 StringBuilder builder = new StringBuilder ();
1516 int temp = 0 ;
@@ -21,7 +22,8 @@ public static final String toBinaryUsingDivideAndModulus(int integer) {
2122 return builder .reverse ().toString ();
2223 }
2324
24- public static final String toBinaryUsingShiftsAndModulus (int integer ) {
25+ public static final String toBinaryUsingShiftsAndModulus (int numberToConvert ) {
26+ int integer = numberToConvert ;
2527 if (integer <0 ) throw new IllegalArgumentException ("Method argument cannot be negative. number=" +integer );
2628 StringBuilder builder = new StringBuilder ();
2729 int temp = 0 ;
@@ -33,7 +35,8 @@ public static final String toBinaryUsingShiftsAndModulus(int integer) {
3335 return builder .reverse ().toString ();
3436 }
3537
36- public static final String toBinaryUsingBigDecimal (int integer ) {
38+ public static final String toBinaryUsingBigDecimal (int numberToConvert ) {
39+ int integer = numberToConvert ;
3740 if (integer <0 ) throw new IllegalArgumentException ("Method argument cannot be negative. number=" +integer );
3841 StringBuilder builder = new StringBuilder ();
3942 BigDecimal number = new BigDecimal (integer );
@@ -46,7 +49,8 @@ public static final String toBinaryUsingBigDecimal(int integer) {
4649 return builder .reverse ().toString ();
4750 }
4851
49- public static final String toBinaryUsingDivideAndDouble (int integer ) {
52+ public static final String toBinaryUsingDivideAndDouble (int numberToConvert ) {
53+ int integer = numberToConvert ;
5054 if (integer <0 ) throw new IllegalArgumentException ("Method argument cannot be negative. number=" +integer );
5155 StringBuilder builder = new StringBuilder ();
5256 double temp = 0d ;
@@ -83,7 +87,8 @@ public static final int euclidsGreatestCommonDivsor(int x, int y) {
8387 return result ;
8488 }
8589
86- public static final boolean powerOfTwoUsingLoop (int number ) {
90+ public static final boolean powerOfTwoUsingLoop (int numberToCheck ) {
91+ int number = numberToCheck ;
8792 if (number == 0 )
8893 return false ;
8994 while (number % 2 == 0 ) {
@@ -94,23 +99,26 @@ public static final boolean powerOfTwoUsingLoop(int number) {
9499 return true ;
95100 }
96101
97- public static final boolean powerOfTwoUsingRecursion (int number ) {
102+ public static final boolean powerOfTwoUsingRecursion (int numberToCheck ) {
103+ int number = numberToCheck ;
98104 if (number == 1 )
99105 return true ;
100106 if (number == 0 || number % 2 != 0 )
101107 return false ;
102108 return powerOfTwoUsingRecursion (number / 2 );
103109 }
104110
105- public static final boolean powerOfTwoUsingLog (int number ) {
111+ public static final boolean powerOfTwoUsingLog (int numberToCheck ) {
112+ int number = numberToCheck ;
106113 double doubleLog = Math .log10 (number ) / Math .log10 (2 );
107114 int intLog = (int ) doubleLog ;
108115 if (doubleLog == intLog )
109116 return true ;
110117 return false ;
111118 }
112119
113- public static final boolean powerOfTwoUsingBits (int number ) {
120+ public static final boolean powerOfTwoUsingBits (int numberToCheck ) {
121+ int number = numberToCheck ;
114122 if (number != 0 && ((number & (number - 1 )) == 0 ))
115123 return true ;
116124 return false ;
@@ -160,8 +168,9 @@ public static final boolean powerOfTwoUsingBits(int number) {
160168 private static final int HUNDRED = 100 ;
161169 private static final int TEN = 10 ;
162170
163- private static final String handleUnderOneThousand (int x ) {
171+ private static final String handleUnderOneThousand (int number ) {
164172 StringBuilder builder = new StringBuilder ();
173+ int x = number ;
165174 int m = x / HUNDRED ;
166175 int r = x % HUNDRED ;
167176 if (m > 0 ) {
@@ -187,9 +196,9 @@ private static final String handleUnderOneThousand(int x) {
187196 return builder .toString ();
188197 }
189198
190- public static final String toEnglish (int x ) {
191- if ( x > Integer . MAX_VALUE || x <= Integer . MIN_VALUE )
192- throw new IllegalArgumentException ("Number has to be <= Integer.MAX_VALUE and > Integer.MIN_VALUE. number=" +x );
199+ public static final String toEnglish (int number ) {
200+ int x = number ;
201+ if ( x > Integer . MAX_VALUE || x <= Integer . MIN_VALUE ) throw new IllegalArgumentException ("Number has to be <= Integer.MAX_VALUE and > Integer.MIN_VALUE. number=" +x );
193202 StringBuilder builder = new StringBuilder ();
194203 if (x ==0 ) {
195204 //Zero is a special case
0 commit comments