import javax.swing.JOptionPane;
import java.util.Arrays;
public class Security
{
public static void main( String[] args)
{
int Nsigma = 0;
int Msigma = 0;
int Osigma = 0;
int[] force = {21,25,96,25,74,66,35,17,85,31,74,36,45,24,93,41,82};
int[] consequence = {4,9,6,3,7,8,2,1,12,16,18,17,19,13,11,10,5};
int[] reference = {21,25,32,41,26,46,12,14,65,85,45,14,82,64,55,87,96};
double fsum = 0;
double csum = 0;
double rsum = 0;
int alpha = 0;
int beta = 0;
double wpi;
String sumtotal;
String RequirementString;
String AnswerString;
String AlphaString;
String BetaString;
String errorstatement = "Invalid Requirement";
RequirementString = JOptionPane.showInputDialog("Enter Requirement Type\n NF, F, D, B, I, or P");
if (RequirementString.equals("NF") || RequirementString.equals("nf"))
{
Nsigma = 5;
Msigma = 10;
Osigma = 15;
AlphaString = JOptionPane.showInputDialog("Enter number between -10 and 10");
BetaString = JOptionPane.showInputDialog("Enter number between -1 and 1");
alpha = Integer.parseInt( AlphaString );
beta = Integer.parseInt( BetaString );
}
else if (RequirementString.equals("F") || RequirementString.equals("f"))
{
Nsigma = 11;
Msigma = 7;
Osigma = 16;
AlphaString = JOptionPane.showInputDialog("Enter number between 0 and 5");
BetaString = JOptionPane.showInputDialog("Enter number between -5 and 5");
alpha = Integer.parseInt( AlphaString );
beta = Integer.parseInt( BetaString );
}
else if (RequirementString.equals("D") || RequirementString.equals("d"))
{
Nsigma = 8;
Msigma = 7;
Osigma = 2;
AlphaString = JOptionPane.showInputDialog("Enter number between 1 and 2");
BetaString = JOptionPane.showInputDialog("Enter number between 1 and 5");
alpha = Integer.parseInt( AlphaString );
beta = Integer.parseInt( BetaString );
}
else if (RequirementString.equals("B") || RequirementString.equals("b"))
{
Nsigma = 17;
Msigma = 5;
Osigma = 11;
AlphaString = JOptionPane.showInputDialog("Enter number between 1 and 5");
BetaString = JOptionPane.showInputDialog("Enter number between 1 and 2");
alpha = Integer.parseInt( AlphaString );
beta = Integer.parseInt( BetaString );
}
else if (RequirementString.equals("I") || RequirementString.equals("i"))
{
Nsigma = 3;
Msigma = 6;
Osigma = 9;
AlphaString = JOptionPane.showInputDialog("Enter number between -5 and 5");
BetaString = JOptionPane.showInputDialog("Enter number between 0 and 5");
alpha = Integer.parseInt( AlphaString );
beta = Integer.parseInt( BetaString );
}
else if (RequirementString.equals("P") || RequirementString.equals("p"))
{
Nsigma = 10;
Msigma = 11;
Osigma = 12;
AlphaString = JOptionPane.showInputDialog("Enter number between -1 and 1");
BetaString = JOptionPane.showInputDialog("Enter number between -10 and 10");
alpha = Integer.parseInt( AlphaString );
beta = Integer.parseInt( BetaString );
}
else
{
JOptionPane.showMessageDialog(null, errorstatement);
System.exit(0);
}
/*Parse integers
alpha = Integer.parseInt( AlphaString );
beta = Integer.parseInt( BetaString );*/
//Summations
for (int i = 0; i <= Msigma; i++)
{
fsum += force[i];
}
for (int j = 0; j <= Nsigma; j++)
{
csum += consequence[j];
}
for (int k = 0; k <= Osigma; k++)
{
rsum += reference[k];
}
sumtotal = fsum + " " + csum + " " + rsum;
fsum += alpha;
csum += beta;
wpi = (fsum + csum) / rsum;
AnswerString = "Wpi is " + wpi;
JOptionPane.showMessageDialog(null, AnswerString);
}
}