0

hey everyone. I am supposed to make a program that finds the smallest number out of a set of numbers. the amount of numbers input is up to the user. i have to print the smallest number, and what input it was (ex, 1st number 2nd number 3rd number...)

i have the code pretty much complete, however i cant figure out how to keep track of whether it was the first second or third number. Do i need to use a do while loop? can i do this with a normal while loop? i thought i could make a counter to keep track of it but i cant quit seem to get it...

this is what i have

```
import java.util.Scanner;
public class WhileLoops2 {
public static void main(String[] args) {
int smallest=0;
int num;
int counter=1;
int numCounter = 0;
int inputVals;
Scanner input=new Scanner (System.in);
System.out.println("Enter number of input values: ");
inputVals = input.nextInt();
System.out.printf("\nEnter a number:");
num=input.nextInt();
smallest=num;
counter++;
while (counter<=inputVals){
System.out.println("Enter another number: ");
num=input.nextInt();
if (num<smallest)
smallest=num;
counter++;}
System.out.println(smallest +" was the smallest number entered.");
System.out.println(smallest +" was input integer number "+numCounter+".");
}
}
```