Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ch10_q8 {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7.  
  8. System.out.println("Please enter a number to see if it has atleast one BiPolar pair: ");
  9. int userInput = sc.nextInt();
  10.  
  11. if (oddEven(userInput) == true) {
  12. System.out.println("The number is BiPolar!");
  13. } else {
  14. System.out.println("The number is not BiPolar!");
  15. }
  16.  
  17. }
  18.  
  19. public static boolean oddEven(int num) {
  20. if (num <= 99 && num > 9) {
  21. int num1 = num / 10;
  22. int num2 = num % 10;
  23. if (num1 % 2 == num2 % 2) {
  24. return false;
  25. } else {
  26. return true;
  27. }
  28. }
  29.  
  30. else {
  31. return oddEven(num / 10);
  32. }
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement