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

Evening Chegg, More Questions. Thank you in advance, I great appreciate your hel

ID: 3568191 • Letter: E

Question

Evening Chegg, More Questions. Thank you in advance, I great appreciate your help.


45. This method takes an array of ints a parameter and returns a single.
dimensional array of booleans. The length of the array returned should be equal

to the number of rows in the two?dimensional array parameter. The element at

index i of the returned array will be true if there is a 0 in the corresponding

row of the parameter array; otherwise, it will be false. Assume that every row

in a has the same number of columns.
Given Code:
[
public static boolean [ ] foo ( int [ ] [ ] a )
{
//your code goes here
//every row has the same number of colums
}


49. This code prints all the elements of languages that start with the letter

P.
Given Code:
[
for ( String s : languages)
{
// your code goes here
}
My Code:
[

]


69. Write a value-returning method that returns the number of elements in
a two-dimensiona array of floats. Include code to test your method.


72. Write a value-returning method that returns the sum of all the ele-
ments in a two-dimensional array of floats. Include code to test your
method.


74. Write a value-returning method that returns the sum of the elements in the

last column of each row in a two-dimensional array of ints. Include code to

test your method.

Explanation / Answer

45. public static boolean [ ] foo ( int [ ] [ ] a )
   {
   //your code goes here
   //every row has the same number of colums
   //Code here
   int i=0,j=0;
   boolean check=true;
   for(i=0;i<a.length;i++)
       {
       check=true;
       for(j=0;j<a[0].length;j++)
           {
           if(a[i][j]!=0)
               check=false;
           }
       if(check==true)
           foo[i]=true;
       else
           foo[i]=false;
       }
   }
  

49. for ( String s : languages)
       {
       // your code goes here
       //Code Here For Case Insensitive Comparison
       if(s.charAt(0)=='P' || s.charAt(0)=='p') //For Case insensitive comparison
           System.out.println(s);  
          
       //Code Here For Case Sensitive Comparison
       if(s.charAt(0)=='P') //For Case Sensitive comparison
           System.out.println(s);      
       }  
      
      
      
69. int numOfElements(float a[][])
       {
       int i=0,j=0,count=0;
       for(i=0;i<a.length;i++)
           {
           for(j=0;j<a[i].length;j++)
               {
               count++;
               }  
           }
       return count;  
       }
      
   void toCheck()throws IOException
       {
       int i=0,j=0;
       float arr[][]=new float[10][10];
       //Initialize array from user input
       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       for(i=0;i<10;i++)
           {
           for(j=0;j<10;j++)
               {
                   arr[i][j]=Float.parseFloat(br.readLine());
               }
           }
       int numOfElements=numOfElements(arr);
       System.out.println(numOfElements);
       }
      
  

72. float sumOfElements(float a[][])
       {
       int i=0,j=0;
       float sum=0.0;
       for(i=0;i<a.length;i++)
           {
           for(j=0;j<a[i].length;j++)
               {
               sum+=a[i][j];
               }  
           }
       return sum;  
       }
      
   void toCheck()throws IOException
       {
       int i=0,j=0;
       float arr[][]=new float[10][10];
       //Initialize array from user input
       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       for(i=0;i<10;i++)
           {
           for(j=0;j<10;j++)
               {
                   arr[i][j]=Float.parseFloat(br.readLine());
               }
           }
       float sumOfElements=sumOfElements(arr);
       System.out.println(sumOfElements);
       }  
      
      
      
74. float sumOfLastElements(float a[][])
       {
       int i=0,j=0;
       float sum=0.0,lastColumn=0.0;
       for(i=0;i<a.length;i++)
           {
               lastColumn=a[i].length-1;
               sum+=a[i][lastColumn];
           }
       return sum;  
       }
      
   void toCheck()throws IOException
       {
       int i=0,j=0;
       float arr[][]=new float[10][10];
       //Initialize array from user input
       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       for(i=0;i<10;i++)
           {
           for(j=0;j<10;j++)
               {
                   arr[i][j]=Float.parseFloat(br.readLine());
               }
           }
       float sumOfLastElements=sumOfLastElements(arr);
       System.out.println(sumOfLastElements);
       }         

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