Computer Science, asked by tjjw13, 1 year ago

Want to become BRAINLIST!!!!
plzz answer the QUESTION in the given IMAGE...

Attachments:

Answers

Answered by mn121
2

import java.util.*;

public class program

{

public static void main(String args[])

{

Scanner in = new Scanner(System.in);

int ch,n,i,f=1;

System.out.println("Enter 1 for displaying the factors of a number and 2 for displaying its factorial = ");

ch=in.nextInt();

switch(ch)

{

case 1: System.out.println("Enter a number = ");

n= in.nextInt();

System.out.println("Factors of "+n+" are:");

for(i=1;i<n;i++)

{

if(n%i==0)

System.out.println(i);

}

break;

case 2: System.out.println("Enter a number = ");

n= in.nextInt();

if(n<=0)

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

else

{

for(i=1;i<=n;i++)

{

f=f*i;

}

System.out.println("Factorial of "+n+" is "+f);

}

break;

default : System.out.println("Wrong Choice");

}

}

}

please mark it as brainliest....

Similar questions