- 2
Can anyone do me the java programming for finding the minimum value and its index in an array
It should be java or python
12 Answers
0
a = [10, 40, 100, 48, 500, 900, 20, 5, 300]
b = min(a), a.index(5)
print(b)
I used python to code it, I don't know whether the way you like it or not. But am sure you can manage it and get some ideas in it.
+ 11
Amirreza Hashemi ,
you are showing a really nice code (*1) to help someone solving a task. we all appreciate this very much!Â
(this is my personal statement - but it is not to criticize someone !!)
but there is an issue by giving a ready solution, when the op has not done and shown his attempt first.
as a part of the community i believe that learning by doing is more helpful, than just using a shared or ready solution. we should act more as a mentor. it is a very successful way when we are giving hints and help, so that the op is able to solve his task by himself.
BTW (*1): i assume that the op is level 5 with 6% of the python core tutorial done. this requires a code that the op can understand. so we should not show what we are able to do, but a way that is helpful for the op. if he can not understand the code, he probably will copy and paste it, without having any real benefits.
thanks for your understanding and your support!
+ 4
Show your attempt
+ 3
Just try to implement what you know. We are always there for you
+ 2
Amirreza Hashemi
"However, it is important to note that members should not post answers to course quizzes without also providing a proper explanation of how the answer was obtained. These âanswer-onlyâ comments are considered unhelpful in terms of promoting the acquisition and retention of programming knowledge among learners and will subsequently be removed by our moderation team."
https://www.sololearn.com/Content-Creation-Guidelines/
(This is from the section on course comments, but the principle should be the same for Q&A.)
+ 2
As a java programmer, I can suggest iterating through each element in the array and assigning the smallest value(int or double) to a variable (int min or double min) and the index of the minimum value to another variable.
+ 1
Mhm
+ 1
At least show your try, people here would surely help you. To be honest, everyone might feel the same at the start. But try to show us your try. Then say what you want to say, so others will understand and fix your code.
0
I got in an interview exam I didn't answer that's why
0
I will share that
0
a=[int(i) for i in input().split()]
print(min(a)),print(a.index(min(a)))
0
In Java, there are tools for that. You can use an ArrayList and Collections.min() to get the minimum value.