Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Check this code out

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Check this code out

    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);
                }
        }





    The assignment was to take basically a sum of two summations and divide it by another summation

    We have to come up for a reason as why did we choose the amount of forces,consequences,and references(the numbers) in the program. Can somebody help me with a rational explanation as to why would my team choose the numbers we chose. Any suggestions would help. Thanks





    Here's the formula(kinda hard to see)
    http://www.javaprogrammingforums.com...6&d=1286647872



    Here is some more information.

    The terms alpha and beta represent different security requirement types that may be altered depending on the individual project requirements of the developer. These security requirements types take on the symbolic values of NF = nonfunctional requirements, F= functional requirements, D=data requirements, B = behavioral requirements, I = interface requirements, P = performance requirements and numeric values. The above listed elements are sufficient to represent any requirements that could be encountered by a developer examining security issues within the security pattern domain.
    Last edited by jwill22; October 11th, 2010 at 05:59 PM. Reason: details


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    489
    Thanks
    8
    Thanked 45 Times in 43 Posts

    Default Re: Check this code out

    Can somebody help me with a rational explanation as to why would my team choose the numbers we chose.
    Huh? Maybe I'm missing something, but it seems to me that if you don't know, who would?

    db

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Check this code out

    Well lets say you were doing the program. What LOGICAL explanation could you give to explain why you used the numbers you did

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    489
    Thanks
    8
    Thanked 45 Times in 43 Posts

    Default Re: Check this code out

    Quote Originally Posted by jwill22 View Post
    Well lets say you were doing the program. What LOGICAL explanation could you give to explain why you used the numbers you did
    Oh, but I didn't. You did.

    db

  5. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Check this code out

    Ok this is getting nowhere fast....so just forget about it. I'd really have to explain in person for anybody to get it

Similar Threads

  1. how to check the value
    By javaking in forum Java Servlet
    Replies: 2
    Last Post: July 22nd, 2010, 06:56 AM
  2. Collision Check Error
    By Josh Yaxley in forum What's Wrong With My Code?
    Replies: 19
    Last Post: July 12th, 2010, 02:12 PM
  3. Check for palindrome numbers
    By SnooSnoo in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 4th, 2010, 05:11 PM
  4. Can Anyone Check This Link
    By arpitgadle in forum Java Servlet
    Replies: 5
    Last Post: October 7th, 2009, 08:56 AM
  5. Problem in AWT and IFrame implementaion
    By AZBOY2000 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: April 24th, 2009, 03:41 AM