double finmin = 0;
to
int finmin = 0;
import java.util.*;
class Mmin{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter 10 numbers: ");
double [] num = new double [10];
int j;
double finmin = 0;
for(j=0; j < num.length; j++){
num[j] = input.nextDouble();
finmin = min(num);
}
System.out.print("your lowest number is: " + (int)finmin);
}
public static double min(double[] num)
{
int j;
double finmin = 0;
for (j = 0; j < num.length; j++){
if (num[j] < j){
finmin = num[j];
}
else{
finmin = num[j];
}
}
return (finmin);
}
}
public static double min(double[] num)
{
int j;
double finmin = num[0];
for (j = 0; j < num.length; j++){
if (num[j] < finmin)
finmin = num[j];
}
return (finmin);
}
and call min() outside the for loop
import java.util.*;
class Mmin{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter 10 numbers: ");
double [] num = new double [10];
int j;
for(j=0; j < num.length; j++){
num[j] = input.nextDouble();
}
Arrays.sort(num);
System.out.println((int)num[0]);
}
}
I need help in figuring out why, as it was stated, I am stuck in a loop.
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
groupSumClump challenge | 9 | 100 | |
What is JNDI datasource in spring | 1 | 50 | |
advertisement module in core php | 4 | 145 | |
Spring Framework HTTPSession management | 1 | 23 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
24 Experts available now in Live!