Computer Science, asked by Anonymous, 3 days ago

Write a program in Java to display three rational numbers between any two Consecutive natural numbers, taking input from the console.

Answers

Answered by jitendrarpatil1979
3

Explanation:

import java.util.Scanner;

public class KboatPronicNumber

{

public void pronicCheck() {

Scanner in = new Scanner(System.in);

System.out.print("Enter the number to check: ");

int num = in.nextInt();

boolean isPronic = false;

for (int i = 1; i <= num - 1; i++) {

if (i * (i + 1) == num) {

isPronic = true;

break;

}

}

if (isPronic)

System.out.println(num + " is a pronic number");

else

System.out.println(num + " is not a pronic number");

}

}

Similar questions