Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
trying to get my program to calculate the number of times a digit appears first in an array and return it in another array. I finished it but it does not seem to compile.
Posted
Updated 20-Oct-12 7:33am
v3

1 solution

Your class name is a number.
A number is not a valid class name and that's why your code don't will be compiled.


The problem is here:
Java
for (int p=0; p<digitpercentage.length; p++) {
        digitpercentage [p] = calculateLeadingDigit (int numbers [i])/numbers.length;
        }


You need to change it into this:
Java
for (int p=0; p<digitpercentage.length; p++) {
        digitpercentage [p] = calculateLeadingDigit ((int) numbers [p])/numbers.length;
        }


You're using the variable p in your loop and not i.
And there was a syntax error at the casting.
 
Share this answer
 
v2
Comments
javamontrealman 20-Oct-12 13:20pm    
sorry, the class name is part4. but thats not the problem. I think there is something wrong with the way I set up the two arrays.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900