#include <iostream>;
#include <cmath>;
 
using namespace std;
 
/* This program decides on how severe an earthquake is 
  Inputs: 
   Magnitude of the earthquake
  Outputs:
    Damage that occurs to buildings
  Logic:
    Lookup table with strings for each range of values.
  Test Cases:
  1) 0, "Minimal damage would occur."
  2) 100, "Are we talking about eathquakes here? \n"
  3)  6.5, "Many buildings damaged. \n"
*/
 
int main()
{
  double magnitude = 0;
  cout << "Please enter the magnitude of the earthquake: " ;
  cin >> magnitude;
 
  if (magnitude < 4.5)
  {
    cout << "Minimal damage would occur. \n";
  }
  else if (magnitude >= 4.5 && magnitude < 6.0)
  {
    cout << "Damage to poorly constructed buildings would occur. \n";
  }
  else if (magnitude >= 6.0 && magnitude < 7.0)
  {
    cout << "Many buildings damaged. \n";
  }
  else if (magnitude >= 7 && magnitude < 8)
  {
    cout << "Many buildings destroyed. \n";
  }
  else if (magnitude >= 8 && magnitude <= 12)
  {
    cout << "Most structures fall. Massive damage. \n";
  }
  else
  {
    cout <<  "Are we talking about eathquakes here? \n";
  }
 
  system("pause");
  return 0;
}
cs-142/earthquakes.txt · Last modified: 2014/09/23 15:51 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0