Answer to Question #172180 in Java | JSP | JSF for Gunal.v

Question #172180

Write a Java Program to print 

the characterization given the Ritcher scale number


1
Expert's answer
2021-03-16T07:43:56-0400
public class RichterScale {
	public static void main(String[] args) {
		double[] arrayLevels = { 5.6, 6.2, 4.0, 5.5, 5.7, 6.1, 7.4, 8.5, 5.5, 6.3, 6.4, 2.1, 6.9, 4.3, 3.1, 7.0, 10.1 };
		double[] arrayLevelsNormal = new double[(arrayLevels.length - 2)];
		int i;
		int minIndex = 0;
		for (i = 1; i < arrayLevels.length; i++) {
			if (arrayLevels[i] < arrayLevels[minIndex]) {
				minIndex = i;
			}
		}
		System.out.print("Min: " + arrayLevels[minIndex] + "    ");


		int maxIndex = 0;
		for (i = 1; i < arrayLevels.length; i++) {
			if (arrayLevels[i] > arrayLevels[maxIndex]) {
				maxIndex = i;
			}
		}
		System.out.println("Max: " + arrayLevels[maxIndex]);
		System.out.println("The Richter values, excluding the extrema, are as follows: ");
		for (i = 1; i < arrayLevels.length - 2; i++) {
			if (arrayLevels[i] != minIndex && arrayLevels[i] != maxIndex) {
				arrayLevelsNormal[i] = arrayLevels[i];
				System.out.printf("%6s\n", arrayLevelsNormal[i]);
			}
		}
	}
}

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