Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with a program, this is one of the classes, the other should be a dr

ID: 655238 • Letter: I

Question

I need help with a program, this is one of the classes, the other should be a driver which tests and shows the results of these interfaces

Fields must be static but interface method heading cannot be static.Any method heading that specifies that an array is returned needs to make a copy of the incoming parameter array and work on that copy,

Do not use any Java API built in-array classes and functions/methods(ArrayList, arraycopy, Arrays.sort)

Write a short main that tests each of your methods and clearly displays the results

public interface ArrayFunctionsInterface
{
public double [ ] sortMe(double [ ] array);
public double getMax(double [ ] array);
public double getMin(double [ ] array);
public int whereAmI(double [ ] array, double searchValue);
public double sumMeUp(double [ ] array);
public double [ ] reverseMe(double [ ] array);
public void printMe(double [ ] array);
public double[ ] doubleMySize(double [ ] array);
}

Explanation / Answer

import java.io.*;

public interface ArrayFunctionsInterface
{
public double [ ] sortMe(double [ ] array);
public double getMax(double [ ] array);
public double getMin(double [ ] array);
public int whereAmI(double [ ] array, double searchValue);
public double sumMeUp(double [ ] array);
public double [ ] reverseMe(double [ ] array);
public void printMe(double [ ] array);
public double[ ] doubleMySize(double [ ] array);
}


class a implements ArrayFunctionsInterface throws IOException
{
   public double[] sortme(double[] array)
   {
       int i,j,c;

       for(i=0;i<array.length;i++)
       {  
           for(j=0;j<=i;j++)
           {
               if(array[j]>array[i])
               {
                   c=array[j];
                   array[j]=array[i];
                   array[i]=c;
               }
           }
       }
       return array;
   }

   public double getMax(double[] array)
   {
        int i,j,c;
       c=a[0];
       for(i=0;i<array.length;i++)
       {  
          
           if(array[i]>c)
           {
               c=array[i];
                  
           }
          
       }
       return c;
   }
  

   public double getMax(double[] array)
   {
        int i,j,c;
       c=a[0];
       for(i=0;i<array.length;i++)
       {  
          
           if(array[i]<c)
           {
               c=array[i];
                  
           }
          
       }
       return c;
   }      

   public int whereAmI(double[] array)
   {
        int i,j,c;

       DataInputStream o = new DataInputStream(System.in);

       System.out.println("Enter Number to find");
       c=Integer.parseInt(o.readLine());  

       for(i=0;i<array.length;i++)
       {  
          
           if(array[i]==c)
           {

               break;
                  
           }
              
       }
       return i;
   }      

   public int sumMeUp(double[] array)
   {
        int i,j,c=0;

       for(i=0;i<array.length;i++)
       {  
          
           c=c+array[i]
                          
       }
       return c;
   }      

}

class dt_ar_fun
{
   public static void main(Striing args[])
   {
       int s;
       double ar[]={12,34,2,44,1};
       double[] arr= new double[];
      
       a o = new a();

       arr=o.sortMe(ar);

       s=o.getMax(ar);
       System.out.println("Max is " + s);

       s=o.getMin(ar);
       System.out.println("Min is " + s);

      
       s=o.whereAmI(ar);
       System.out.println("Given number is at " + s);

       s=o.sumMeUp(ar);
       System.out.println("Sum is " + s);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote