The National Earthquake Information Center has asked you to write a program impl
ID: 2079930 • Letter: T
Question
The National Earthquake Information Center has asked you to write a program implementing the following decision table to characterize an earthquake based on its Richter scale number. Requirement: 1. Must use an if elseif ...-else structure. 2. Cannot use Logic Operators (program structure should be similar to letter grade example). 3. Read in a value for n using the input command and then display the corresponding characterization message using fprintf. 4. Examples: Enter the earthquake Richter Scale Number: -2 Richter Scale Number must be greater than 0! Enter the earthquake Richter Scale Number: 6.5 For a Richter Scale Number of 6.50 Earthquake Characterization is: Disaster: houses and buildings may collapse Enter the earthquake Richter Scale Number: 7.7 For a Richter Scale Number of 7.70 Earthquake Characterization is: Catastrophic: most buildings destroyedExplanation / Answer
clc; clear all; close all;
n=input('Enter Richter scale value :');
if(n>=7.5)
fprintf('Earthquake Characterization: Catastropic: most buildings destroyed ');
elseif(n>=6.5 && n<7.5)
fprintf('Earthquake Characterization: Diaster: houses and buildings may collapse ');
elseif(n>=5.5 && n<6.5)
fprintf('Earthquake Characterization: Serious damage: walls may crack or fall ');
elseif(n>=5.0 && n<5.5)
fprintf('Earthquake Characterization: Some damage ');
elseif(n>=0 && n<5.0)
fprintf('Earthquake Characterization: Little or no damage ');
else
fprintf('Richter Scale number must be greater than 0! ');
end
OUTPUT:
Enter Richter scale value :-2
Richter Scale number must be greater than 0!
>>
Enter Richter scale value :6.9
Earthquake Characterization: Diaster: houses and buildings may collapse
>>
Enter Richter scale value :9.9
Earthquake Characterization: Catastropic: most buildings destroyed
>>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.