Write a Java Program to print
the characterization given the Ritcher scale number
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]);
}
}
}
}
Comments
Leave a comment