how to do????plz tell me anyone
Answers
Answer:
import java.util.*;
class solution{
public static void main() {
Scanner sc = new Scanner(System.in);
//Printing the menu
System.out.println("1. Check and display if the number is composite");
System.out.println("2. Exit");
//Taking user input
System.out.println("Please enter your choice!");
int choice = sc.nextInt();
//Creating the switch statement
switch(choice) {
case 1:
System.out.println("Please enter the number to be checked.");
//Taking user input for number to be checked
int num = sc.nextInt();
//Calling composite method by passing num
composite(num);
break;
case 2:
System.exit(0);
//checking for wrong input
default:
System.out.println("Sorry, you have entered a wrong choice");
break;
}//end of switch
}//end of main method
//starting composite method declaration
public static void composite(int n) {
for(int i = 2; i < n; i++) {
if(n%i == 0) {
//If the number n has any factors, we print it is composite and
//stop the program
System.out.println("The number " + n + " is composite.");
System.exit(0);
}//end of if
}//end of for
System.out.println("The number " + n + " is not composite");
}//end of composite method
}//end of class
// It would be highly appreciated if you could mark this the brainliest answer as I put a lot of time and effort into this one. Thanks!