Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prit1199 patch 1 #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions ch_06/Exercise06_03.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,17 @@ public static void main(String[] args) {
}

public static int reverse(int number) {
String temp = "";
while (number > 0) {
int t = number % 10;
number /= 10;
temp += t;

}
return Integer.parseInt(temp);
int reverseNum = 0;
while( n != 0){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few formatting issues, just use the built in formatting for Java on your IDE

reverseNum = reverseNum *10;
reverseNum += number % 10 ;
number = number / 10;
}
return reverseNum;
}

public static boolean isPalindrome(int number) {
String n1 = String.valueOf(number);
String n2 = String.valueOf(reverse(number));

return n1.equals(n2);

return ( number == reverse(number))
}
}

}