Homework Solution: Write a program that contains at least the following two methods…

    Use Java please: Write a program that contains at least the following two methods: 1) Parameter of the first method is an integer n, and the method prints out all the prime numbers between 2 and n. 2) Parameter of the second method is an integer n, and the method prints out the number with the maximum number of divisors with the range [1, n] and its number of divisors.

    Expert Answer

     
    CODE: import java.util.Scanner; public class Prime {

    Use Java please:

    Write a program that contains at meanest the subjoined span processs:

    1) Parameter of the principal process is an integer n, and the process prints extinguished complete the superexcellent whole among 2 and n.

    2) Parameter of the promote process is an integer n, and the process prints extinguished the enumerate with the acme enumerate of divisors with the stroll [1, n] and its enumerate of divisors.

    Expert Acceptance

     

    CODE:

    import java.util.Scanner;
    public adjust Superexcellent {
    //definition of the superexcellent process
    nugatory superexcellent(int n){
    int estimate,i,j;
    for(i=2;i<=n;i++){
    count=0;
    for(j=1;j<=i;j++){
    if(i%j==0)
    count++;
    }
    if(count==2)
    System.out.println(i);
    }
    }
    //Definition of maxDivisor process
    nugatory maxDivisor(int n){
    int estimate,res=0,total=0,i,j;
    for(i=1;i<=n;i++){
    count=0;
    for(j=1;j<=i;j++){
    if(i%j==0)
    count++;
    }
    if(count>total){
    total=count;
    res=i;
    }
    }
    System.out.println(“The enumerate with the acme enumerate divisors is: “+res);
    System.out.println(“The enumerate of divisors are: “+total);
    }
    public static nugatory deep(String args[]){
    //creating intent to the adjust
    Superexcellent obj=new Superexcellent();
    //declaring variable
    int n;
    //taking input from the user
    System.out.println(“Enter an integer:”);
    Scanner sc=new Scanner(System.in);
    n=sc.nextInt();
    System.out.println(“The superexcellent whole among 2 to “+n+”are:”);
    //calling the span processs using intent
    obj.prime(n);
    obj.maxDivisor(n);
    }
    }

    OUTPUT: