Machine Problem: 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:
Richter Scale Number (n) Characterization
n < 5.0 Little or no damage
5.0 <= n < 5.5 Some damage
5.5 <= n < 6.5 Some damage; walls may crack or fall
6.5 <= n < 7.5 Disaster: houses and buildings may collapse
higher Catastrophe: Most buildings destroye
Source code
#include <iostream>
using namespace std;
int main()
{
double n;
cout<<"\nEnter Richter Scale Number (n): ";
cin>>n;
if (n<5.0)
cout<<"\nLittle or no damage";
else if (n>=5.0 && n<5.5)
cout<<"\nSome damage";
else if (n>=5.5 && n<6.5)
cout<<"\nSome damage; walls may crack or fall ";
else if (n>=6.5 && n<7.5)
cout<<"\nDisaster: houses and buildings may collapse ";
else if (n>7.5)
cout<<"\nCatastrophe: Most buildings destroyed ";
return 0;
}
Sample Output
Comments
Leave a comment