1- Write a Program to check prime number or not in Java

1- Write a Program to check prime number or not in Java :

class PrimeNo

{

public static void main(String args)

{

int n, i, res;

boolean flag = true;

Scanner sc = new Scanner(System.in);

System.out.println(“Enter a Nnumber.”);

n = sc.nextInt();

for (i = 2; i 0);

return (prefix + current).trim();

}

public static void main(String args)

{

System.out.print(“Enter a number: “);

Scanner sc = new Scanner(System.in);

int num = sc.nextInt();

System.out.println();

NumberToWord obj = new NumberToWord();

System.out.println(num + ” = ” + obj.convert(num));

}

}

Output:

Enter a number

1000= One Thousand

3- Write a program to find factorial of a number in Java :

class Factorial

{

public static void main(String args)

{

int fact = 1;

int number = 0;

System.out.println(“Enter a number :”);

Scanner in = new Scanner(System.in);

number = in.nextInt();

for (int i = 1; i y && x > z)

System.out.println(“First number is largest.”);

else if (y > x && y > z)

System.out.println(“Second number is largest.”);

else if (z > x && z > y)

System.out.println(“Third number is largest.”);

else

System.out.println(“Entered numbers are not distinct.”);

}

}

Output:

Enter three no

1 2 3

Third number is largest