What answer are you getting that's incorrect? That's what is puzzling. I looked at your code, but I don't see any division, percentage calculation, or output.
I compiled and ran your code. Here's the output I got. So far, so good. What's wrong? What's your question?
"C:\Program Files\Java\jdk1.7.0_02\bin\java" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 120.11\bin" com.intellij.rt.execution.application.AppMain cruft.Integers
How many numbers will you enter?
4
Enter 4 integers, one per line:
2
1
1
2
The sum is 16.
The numbers are:
Process finished with exit code 0
Write more code. Be careful to remember that integer division isn't what you want; percentages need to be doubles.
int x = 1/2; // x will equal zero. know why?
You've already calculated the sum. You know that if you take in ten numbers, no matter how many or what their values are, the percentage of the sum that each one will represent is the number divided by the sum. Is that what you're asking?
1 hour later:
It's been a whole hour, and you seem to think that writing comments is more educational than actually writing the four lines of code that you need. Okay, I'll bite - here's your solution. I'll risk the wrath of all those who will be outraged by someone who does homework. I want you to see how ridiculous it is that you wouldn't even attempt four lines of code:
import java.util.Scanner;
public class Integers {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("How many numbers will you enter?");
int size = keyboard.nextInt();
int[] entry = new int[size];
System.out.println("Enter " + entry.length + " integers, one per line:");
int sum = 0;
for (int index = 0; index < entry.length; index++) {
entry[index] = keyboard.nextInt();
sum += entry[index]; // this was wrong - I fixed it.
}
// This is all you had to do.
for (int anEntry : entry) {
System.out.println(String.format("value: %d %6.2f%%", anEntry, anEntry * 100.0 / sum));
}
System.out.println(String.format("total: %d %6.2f%%", sum, 100.0));
}
}