Write a Java program to manipulate grades Arrays A B contai

Write a Java program to manipulate grades.

Arrays A & B contain 6 grades.

Add two arrays. C = A + B

Average array C

Increase array C by 10 %

Print the arrays (using the enhanced for) and list shuld be from least to greatest

Solution

import java.util.Arrays;
import java.util.Collections;


public class Grades {
   public static void main(String[] args)
   {
       int A[] = {90, 80, 90, 70, 80, 95};
       int B[] = {98, 90, 97, 89, 67, 88};
      
       Double[] C = new Double[6];
      
       // sum A and B
       for (int i = 0; i < 6; i++)
       {
           C[i] = (double) (A[i] + B[i]);
       }
      
       // Average C
       for(int i = 0; i < 6; i++)
       {
           C[i] = C[i] /2.0;
       }
      
       // Increase by 10%
       for(int i = 0; i < 6; i++)
       {
           C[i] = C[i] + C[i]*10/100;
       }

       Arrays.sort(C, Collections.reverseOrder());      
      
       for(double c : C)
       {
           System.out.println(\"Grade is \" + c);
       }
   }
}

Write a Java program to manipulate grades. Arrays A & B contain 6 grades. Add two arrays. C = A + B Average array C Increase array C by 10 % Print the array

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site