Answer to Question #47575 in C++ for krad

Question #47575
6. The national earthquake information center has the following criteria to determine the earthquake’s damage. Here are the given richter scale criteria and their corresponding characterization. The richter scale serves as the inoput data and the characterization as output information.
Richter Number (n) Characterization
N<5.0 Little Or No Damage
5.0>=N<5.5 Some Damage
5.5>=N<6.5 Serious Damage
6.5>=N<7.5 Disaster
Higher Catastrophe

In Switch Case
1
Expert's answer
2014-10-06T02:16:56-0400
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;
int main()
{
float richterNumber;
const int LITTLE_OR_NO_DAMAGE = 0;
const int SOME_DAMAGE = 1;
const int SERIOUS_DAMAGE = 2;
const int DISASTER = 3;
const int CATASTROPHE = 4;
cout<<"Enter the Richter number"<<endl;
cin>>richterNumber;
if (richterNumber < 5.0) richterNumber = LITTLE_OR_NO_DAMAGE;
if (richterNumber >= 5.0 && richterNumber < 5.5) richterNumber = SOME_DAMAGE;
if (richterNumber >= 5.5 && richterNumber < 6.5) richterNumber = SERIOUS_DAMAGE;
if (richterNumber >= 6.5 && richterNumber < 7.5) richterNumber = DISASTER;
if (richterNumber >= 7.5) richterNumber = CATASTROPHE;
switch((int)richterNumber)
{
case LITTLE_OR_NO_DAMAGE:
cout<<"Little Or No Damage"<<endl;
break;
case SOME_DAMAGE:
cout<<"Some Damage"<<endl;
break;
case SERIOUS_DAMAGE:
cout<<"Serious Damage"<<endl;
break;
case DISASTER:
cout<<"Disaster"<<endl;
break;
case CATASTROPHE:
cout<<"Catastrophe"<<endl;
break;
}
system("pause");
return 0;
}


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
APPROVED BY CLIENTS