+ 3
Java Question
Write a program that gets n values from user, store these values in an array of n numbers. Your program then must display the particular element to the user whose individual digits when multiplied with each other results into highest value in that array. For example: if the array contains 10, 123, 65, 93, then 65 must be displayed because (65): 6 x 5 = 30, is higher than other values For example: (10): 1 x 0 = 0 (123): 1 x 2 x 3 = 6 (93): 9 x 3 = 27
4 ответов
+ 19
J 12323123 your response is really helpful, thanks, but I'm stuck with the second step 😅 I feel extremely stupid, but what need we do to get 2 ints 6 and 5 from an(int)65 that we stored at say [0] index of our array? 🤔 (beginner here, not used to challenges)
+ 12
Okay start by writing it out in pseudocode. Take in values with a loop, put the values into an array. Then loop through the values once stored in an array. Get the individual values and store in a varialble. Multiple the value by itself ie 6*5. Then have a max value. Compare the values, in a sort method to see which one is the highest. Then print out the highest to lowest.
Code could be done with variables, loops, array, a sort method, or a compare method. Hope that helps. I always work this way. start with pseudocode, or diagrams, and drawings, write out a first attempt and get it working, then polish your code to get a more efficient program.
+ 11
1Lory☕ I am a beginner, just adding my thoughts on the program. Maybe someone else can share their thoughts. Yes, the array will need to be looped through to get the value of 65 and then multiply itself by it. Hmm I think the % would be very useful here say int x % 10. break the value down, seperate it