Justin
2010-10-16 16:55:53 UTC
import javax.swing.JOptionPane;
import java.util.Arrays;
public class Security
{
public static void main( String[] args)
{
int Msigma = 8;
int Nsigma = 7;
int Osigma = 10;
double[] force = {21,25,27,45,52,71,78,96}; //Number of nodes on network connected directly to server
double[] consequence = {32,26,34,22,92,51,65};//Number of intrusions
double[] reference = {21,25,32,41,26,46,56,35,17,12};//Number of internetworked connections
double fsum = 0;
double csum = 0;
double rsum = 0;
int alpha = 0;
int beta = 0;
double wpi;
String AnswerString;
String AlphaString;
String BetaString;
AlphaString = JOptionPane.showInputDialog("Enter number between 10 and 25");
BetaString = JOptionPane.showInputDialog("Enter number between 0 and 10");
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];
}
fsum += alpha;
csum += beta;
wpi = (fsum + csum) / rsum;
AnswerString = "Wpi is " + wpi;
JOptionPane.showMessageDialog(null, AnswerString);
}
}
How does a loop works...I haven't studied it yet. This is a code for a assignment my group was supposed to do. Can somebody explain to me please?