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)
The user has to enter in the numbers

Solution

Hi, Please find my implementation.

Please let me know in case of any issue.

import java.util.Scanner;

public class GradesManupulation {

  

   public static void main(String[] args) {

      

       Scanner sc = new Scanner(System.in);

      

       // declaring two array

       double[] A = new double[6];

       double[] B = new double[6];

      

       // getting user input

       System.out.println(\"Enter 6 grades for first array: \");

       for(int i=0; i<6; i++)

           A[i] = sc.nextDouble();

      

       System.out.println(\"Enter 6 grades for second array: \");

       for(int i=0; i<6; i++)

           B[i] = sc.nextDouble();

      

       // declaring third array that stores sum of both array

       double[] C = new double[6];

      

       for(int i=0; i<6; i++)

           C[i] = A[i] + B[i];

      

       // printing C

       System.out.println(\"C = A+B\");

       for(double grade : C)

           System.out.print(grade+\" \");

       System.out.println();

      

       // increasing C by 10%

       for(int i=0; i<6; i++)

           C[i] = C[i] + C[i]*0.1;

      

       // printing all three arrays

       System.out.println(\"A: \");

       for(double grade: A)

           System.out.print(grade+\" \");

       System.out.println();

       System.out.println(\"B: \");

       for(double grade: B)

           System.out.print(grade+\" \");

       System.out.println();

       System.out.println(\"C= C+ C*0.1 \");

       for(double grade: C)

           System.out.print(grade+\" \");

       System.out.println();

      

   }

}

/*

Sample run:

Enter 6 grades for first array:

76.5 45 77.6 87 98.5 65.4

Enter 6 grades for second array:

89 90 96.5 79.8 87.5 80

C = A+B

165.5 135.0 174.1 166.8 186.0 145.4

A:

76.5 45.0 77.6 87.0 98.5 65.4

B:

89.0 90.0 96.5 79.8 87.5 80.0

C= C+ C*0.1

182.05 148.5 191.51 183.48000000000002 204.6 159.94

*/

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
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
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