Correct my code, it is supposed to  return each index as a percentage of the original array  public static double[] getPercentages(double[] data) {  double sum = 0.0;   double [] data = (6.0, 5.0, 4.0, 5.0);  double[] percentages = getPercentages(data);    for (double num : data) {       sum += num;    }  double [] percentages = new double[data.length];  for (int i =0; i< data.length; i++) {  percentages[i]= data / sum; } return percentages; }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question

Correct my code, it is supposed to  return each index as a percentage of the original array 

public static double[] getPercentages(double[] data) {

 double sum = 0.0; 

 double [] data = (6.0, 5.0, 4.0, 5.0);

 double[] percentages = getPercentages(data);

   for (double num : data) {

      sum += num;

   }

 double [] percentages = new double[data.length];

 for (int i =0; i< data.length; i++) {

 percentages[i]= data / sum;

}

return percentages;

}

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT