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.
Title | # Comments | Views | Activity |
---|---|---|---|
wordappend challenge | 8 | 85 | |
What is the latest versions eclipse neon | 2 | 120 | |
Java passing arguments (type error) | 2 | 35 | |
Responding to Java JComponent extended classes's resize event | 4 | 26 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
23 Experts available now in Live!