Created
October 23, 2022 20:57
-
-
Save chamellion/998459b18196382640eac7af68732066 to your computer and use it in GitHub Desktop.
CSCM_41 LAB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class LabThreeQ2 { | |
public static void main(String[] args) { | |
System.out.println("Please enter the earthquake magnitude below: "); | |
String smallShake = "Noticeable shaking of indoor objects and rattling noises." + | |
" Felt by most people in the affected area. Slightly felt outside. " + | |
"Generally causes zero to minimal damage. Moderate to significant damage very unlikely." + | |
" Some objects may fall off shelves or be knocked over."; | |
String semiMedium = "Can cause damage of varying severity to poorly constructed buildings. " + | |
"Zero to slight damage to all other buildings. Felt by everyone."; | |
String medium = "Causes damage to most buildings, some to partially or completely collapse or receive severe damage." + | |
" Well-designed structures are likely to receive damage. " + | |
"Felt across great distances with major damage mostly limited to 250 km from epicenter."; | |
String large = "At or near total destruction – severe damage or collapse to all buildings." + | |
" Heavy damage and shaking extends to distant locations. " + | |
"Permanent changes in ground topography."; | |
Scanner scanner = new Scanner(System.in); | |
if (scanner.hasNextDouble()) { | |
double magScale = scanner.nextDouble(); | |
if (magScale > 0 && magScale < 5.0) { | |
System.out.println(smallShake); | |
} else if (magScale > 5 && magScale < 6) { | |
System.out.println(semiMedium); | |
} else if (magScale > 6 && magScale < 8) { | |
System.out.println(medium); | |
} else if (magScale > 8) { | |
System.out.println(large); | |
} else { | |
System.out.println("Magnitude is usually greater than 0. Please check again and try later..."); | |
} | |
} else { | |
System.out.println("Invalid numbers entered. Please try again"); | |
main(null); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment