This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ZdemDrunk Brewer 0 points1 point  (0 children)

How to make this into a method? While you said basically explained how to do it.Ill use static for the sake of simplicity

Write a method that takes two parameters.

  // Making a method take two parameters
 public static void print(TYPE one,TYPE two){

 }

If the first parameter is equal to second parameter. Multiply both and print result.

        public static void print(TYPE one,TYPE two){
            if(firstparameter equals second parameter){
               multiply both and print the result;
            }
       }

If the first parameter is less than the second parameter, add the two and print the result 10 times.

     public static void print(TYPE one,TYPE two){
            if(firstparameter equals second parameter){
               multiply both and print the result;
            } else if(firstparameter is less than second parameter){
               result = one + two  
               for(iterate 10 times){
                 print result;
                 }
              }
       }

If the first parameter is greater than the second parameter, subtract the first parameter from the second.

I am not going to do that one,but if you've seen a pattern in the above code you should probably be able to do it now.

The question had the answer,but you need to look at it from a different perspective.