Answer to Question #284779 in Java | JSP | JSF for Isman

Question #284779

Write a program to create a SDA to store 15 numbers . Then create another array to store their unit digits. Then display values of first array in one line if the value in second array exceeds 5. And also display how many such numbers found.


1
Expert's answer
2022-01-04T08:56:23-0500
import java.util.Scanner;


public class App {


	private static int numbersCounter(int numbersUnitDigits[], int number) {
		int counter = 0;


		for (int i = 0; i < numbersUnitDigits.length; i++) {
			if (number == numbersUnitDigits[i]) {
				counter++;
			}
		}


		return counter;
	}


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		int numbers[] = new int[15];
		int numbersUnitDigits[] = new int[15];


		for (int i = 0; i < 15; i++) {
			System.out.print("Enter the number " + (i + 1) + ": ");
			numbers[i] = keyBoard.nextInt();
			numbersUnitDigits[i] = numbers[i] % 10;
		}


		for (int i = 0; i < 15; i++) {
			if (numbers[i] == numbersUnitDigits[i]) {
				System.out.println(numbers[i] + "  " + numbersCounter(numbersUnitDigits, numbers[i]));
			}
		}


		keyBoard.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