Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Ch10_q8 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Please enter a number to see if it has atleast one BiPolar pair: ");
- int userInput = sc.nextInt();
- if (oddEven(userInput) == true) {
- System.out.println("The number is BiPolar!");
- } else {
- System.out.println("The number is not BiPolar!");
- }
- }
- public static boolean oddEven(int num) {
- if (num <= 99 && num > 9) {
- int num1 = num / 10;
- int num2 = num % 10;
- if (num1 % 2 == num2 % 2) {
- return false;
- } else {
- return true;
- }
- }
- else {
- return oddEven(num / 10);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement