troubleshooting Question

Min Value and Print User input

Avatar of chris0044
chris0044 asked on
4 Comments2 Solutions272 ViewsLast Modified:

I' m student and I'm having trouble printing out the minimum value and also to print out what the user inputs. Could someone tell me what I'm doing wrong?

public static void main(String args[]){
	int numbers;
	int inputData = 0;
	int largest = 0;
	int smallest = inputData;
	Scanner scan = new Scanner(;
		System.out.print("How many numbers do you want to enter?");
		numbers = scan.nextInt();
		for (int index = 1; index <= numbers; index ++){
		System.out.print("Number " + index + ": ");
		inputData = scan.nextInt();
		if (inputData > largest){
			largest = inputData;
			if (inputData < smallest){
				smallest =inputData;
		System.out.println ("largest Value is " + largest);
		System.out.println ("smallest Value is " + smallest);
		System.out.println("You've entered: ");
		for (int index = 1; index <= numbers; index ++){
			System.out.print(inputData + " ");

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros