rendered paste bodyimport javax.swing.*;
public class A2Q2
{
public static void main (String [] args)
{
String input;
String output;
char pick;
double value;
final char pH = 'A';
final char HURRICANE = 'B';
final char RITCHER = 'C';
final char QUIT = 'X';
pick = 'z';
while(pick!= QUIT){
input = JOptionPane.showInputDialog ("Choose a scale:" +"\n"+
"A - pH Scale" +"\n"+
"B - Simpson-Saffir Hurricane Scale" +"\n"+
"C - Ritcher Scale" +"\n"+
"X - Quit");
if(input == null || input.length() == 0){input = "null";
JOptionPane.showMessageDialog(null, "Please choose a scale");
System.out.println("Please choose a scale.");
}
input = input.toUpperCase();
pick = input.charAt(0);
if(pick == QUIT) {output = "ya, your welcome";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(pick == pH)
{input = JOptionPane.showInputDialog ("Enter the pH value");
value = Double.parseDouble(input);
if(value<0 || value>14) {output = "The pH value you have input is invalid";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=0 && value<7){output = "A pH of " + value + " is acidic";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value == 7) {output = "A pH of 7 is neutral";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>7 && value<=14) {output = "A pH of " + value + " is basic";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
}
if(pick == HURRICANE)
{input = JOptionPane.showInputDialog ("Enter a Wind speed");
value = Double.parseDouble(input);
if(value<0) {output = "This scale doesn't measure vacuums...";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>0 && value<63) {output = "Tropical depression";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=63 && value<=118) {output = "Tropical Storm";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=119 && value<=153) {output = "Hurricane Category: 1"+"\n"+
"No real damage to building structures.";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if (value>=154 && value<=177) {output =
"Hurricane Category: 2"+"\n"+ "Some roofing material, door and window damage.";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=178 && value<=209) {output =
"Hurricane Category: 3"+"\n"+ "Mobile homes are destroyed; flooding near the coast destroys smaller structures.";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=210 && value<=249) {output =
"Hurricane Category: 4"+"\n"+ "Major erosion of beach areas; terrain may be flooded well inland.";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>249) {output =
"Hurricane Category: 5"+"\n"+ "Complete roof failure on many residences; massive evacuation of residential areas may be required";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
}
if(pick == RITCHER)
{input = JOptionPane.showInputDialog ("Enter a Richter value");
value = Double.parseDouble (input);
if(value<0) {output = "Invalid input";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value<2) {output = "Richter Magnitude: "+ value
+"\n"+ "Microearthquake"
+"\n"+ "Microearthquake; not felt";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=2 && value<=2.9) {output = "Richter Magnitude: "+ value
+"\n"+ "Very Minor earthquake"
+"\n"+ "generally not felt, but recorded";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=3 && value<=3.9) {output = "Richter Magnitude: "+ value
+"\n"+ "Minor earthquake"
+"\n"+ "Often felt but rarely causes damage";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=4 && value <= 4.9) {output = "Richter Magnitude: "+ value
+"\n"+ "Light Earthquake"
+"\n"+ "noticeable shaking of indoor items; significant damage unlikely";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if (value>=5 && value<= 5.9) {output = "Richter Magnitude: "+ value
+"\n"+ "Moderate Earthquake"
+"\n"+ "can cause major damage to poorly constucted buildings, slight damage to well-designed buildings";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=6 && value<=6.9) {output = "Richter Magnitude: "+ value
+"\n"+ "Strong"
+"\n"+ "can be destructive in areas up to around 150km across";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=7 && value<=7.9) {output = "Richter Magnitude: "+ value
+"\n"+ "Major Earthquake"
+"\n"+ "can cause serious damage over larger areas";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=8 && value <=8.9) {output = "Richter Magnitude: "+ value
+"\n"+ "Great Earthquake"
+"\n"+ "can cause serious damage in areas several hundred kilometres across";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
else if(value>=9) {output = "Richter Magnitude: "+ value
+"\n"+ "Rare great Earthquake"
+"\n"+ "devastating in areas several thousand kilometres across";
JOptionPane.showMessageDialog (null, output);
System.out.println (output);}
}
}
System.out.println ("\n"+"Programmed by Christian Hall" +"\n"+
"Date: 2006-Oct-17" +"\n"+
"***Ending of Processing***" );
System.exit(0);
}
}