I am taking ap java in high school. We have a project.
I cant figure this out help me out please!
For each multiple of 10 in the given array change all the values following it to be that multiple of 10, untill encountering another mulltiple of 10.
Example: 2,10,3,4,20,5 becomes 2,10,10,10,20,20
..........: 10,1,20,2 becomes 10,10,20,20
public static int multsOfTen(int nums)
Re: Help! PLEASE!
Since you return an array you should build a new array as you go through the loop. You have three possible outcomes. The first is when no power of 10 is reached (either skip this value or add it to the new array, and the second case is if a power of 10 is encountered. From here on you do two things at each step, check the next value if an array, if it is not a multiple of 10, replace it with the current multiple of 10, otherwise store the new multiple of 10 and repeat. No one here is going to give you code for this. While this description may be a bit confusing, try to understand it and apply it. Some psudo code
declare current multiple
add multiple of 10 to array
continue on or put value into new array
save current multiple of 10
add current multiple or continue