Computer Science, asked by ItzBrainlyQueen01, 1 month ago

Write a Java program for this​

Attachments:

Answers

Answered by akawars16
3

import java.io.*;

class Glorious

{

public static void main () throws IOException

{

Buffered Reader input = new Buffered Reader new (Input Stream Reader (system.in));

System.out.println("Enter a number");

int n= Integer.parseInt (input.readLine));

System.out.println("Please enter your choice-");

System.out.println("Choose 1 for checking prime number");

System.out.println("Choose 2 for checking automorphic number");

String s=input.readLine();

int t = Integer.parseInt (s);

Switch (t);

{

case 1:

int c= 0;

for int (j=2; j<n; j++)

{

if (n%j==0)

{

c= c+1;

}

}

if (c==0)

{

System.out.println("Number is a prime number");

}

else

{

System.out.println("Number is not a prime number");

}

case 2:

int k=n;

int a=n;

int d =0;

while (a<0)

{

d =d+1;

a=a/10;

}

int k=a*a;

int b=Math.pow(10,d);

int l = k%b;

if (l==k)

{

System.out.println("Number is automorphic number");

}

else

{

System.out.println("Number is not a automorphic number");

}

}

}

}

Similar questions