ed81
11-11-2005, 01:00 PM
Hi:
I am sorry to bother again, thank you oak for the help the other day and I thought i was going to have a better idea about the program but i cant still run it the way the professor wants it and its due tomorrow. The proffessor wants it as simple as it can be i have this:(I know i must have thousands of errors but how would you correct this with what is here and simplest way as possible)
USER INPUTS ANY AMOUNT OF VALUES AND GETS THE SMALLER AT THE END
import java.util.Scanner;
public class Smaller {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int c;
int min;
min = 0;
System.out.println("How many numbers you wish to enter?");
c = input.nextInt();
int n;
for (int counter = 1; counter<=c; counter++)
{
System.out.println("Please Enter the next number");
n = input.nextInt();
//HERE I NEED TO JUST USE THE IF STATEMENT TO GET IT RIGHT
//HAVE TRIED EVERYTHING.. EXCEPT THE RIGHT ONE
//HE SAYS THAT I JUST NEED TO STORE THE MINIMUM VALUE TO THE INT
//MIN AND THAT IT SHOULD DO
//I HAVE:
if (min<n) //i dunno how to compare it and get the value saved to min
{
System.out.println(min);
}
else
i dunno what to put here..
// need to compare with small here, update the smaller # to small (this was written by my professor)
}
}
}
I am so sorry to disturb you and take from your valuable time but i know you can give me the answer here np..
Best Regards and thank you very much
Ed
I am sorry to bother again, thank you oak for the help the other day and I thought i was going to have a better idea about the program but i cant still run it the way the professor wants it and its due tomorrow. The proffessor wants it as simple as it can be i have this:(I know i must have thousands of errors but how would you correct this with what is here and simplest way as possible)
USER INPUTS ANY AMOUNT OF VALUES AND GETS THE SMALLER AT THE END
import java.util.Scanner;
public class Smaller {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int c;
int min;
min = 0;
System.out.println("How many numbers you wish to enter?");
c = input.nextInt();
int n;
for (int counter = 1; counter<=c; counter++)
{
System.out.println("Please Enter the next number");
n = input.nextInt();
//HERE I NEED TO JUST USE THE IF STATEMENT TO GET IT RIGHT
//HAVE TRIED EVERYTHING.. EXCEPT THE RIGHT ONE
//HE SAYS THAT I JUST NEED TO STORE THE MINIMUM VALUE TO THE INT
//MIN AND THAT IT SHOULD DO
//I HAVE:
if (min<n) //i dunno how to compare it and get the value saved to min
{
System.out.println(min);
}
else
i dunno what to put here..
// need to compare with small here, update the smaller # to small (this was written by my professor)
}
}
}
I am so sorry to disturb you and take from your valuable time but i know you can give me the answer here np..
Best Regards and thank you very much
Ed