Answer to Question #324294 in Java | JSP | JSF for Angge

Question #324294

Create a program that will allow the user to input ten numbers into an array, using values of 0 to 99, and print out all numbers except for the largest number and the smallest number.

Sample Output:

Enter the Numbers >> 10 20 10 40 50 60 70 80 90 99

Output >> 20 40 50 60 70 80 90

Try Again Y/N?


1
Expert's answer
2022-04-05T17:28:52-0400


import java.util.Scanner;


public class App {


	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String answer = "";
		while (answer.compareToIgnoreCase("n") != 0) {
			int[] numbers = new int[10];


			System.out.print("Enter the Numbers >>  ");
			for (int i = 0; i < 10; i++) {
				numbers[i] = in.nextInt();
			}
			int min = numbers[0];
			int max = numbers[0];
			for (int i = 0; i < 10; i++) {
				if (min > numbers[i]) {
					min = numbers[i];
				}
				if (max < numbers[i]) {
					max = numbers[i];
				}
			}


			System.out.print("Output >> ");
			for (int i = 0; i < 10; i++) {
				if (min != numbers[i] && max != numbers[i]) {
					System.out.print(numbers[i] + " ");
				}
			}
			in.nextLine();
			System.out.print("\nTry Again Y/N? ");
			answer = in.nextLine();
		}


		in.close();
	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS