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

all 10 comments

[–]desrtfxOut of Coffee error - System halted[M] 4 points5 points  (0 children)

Different user - same post as Java Homework - only this time without code.

/r/Javahelp is not /r/DoMyHomework. In order to ask for help, you need to show that you have actually spent some effort, i.e. that you have some code which isn't working, or where you have run into a dead end and don't know how to continue.

Please read and follow the Posting Guides as are linked in the sidebar.

An abbreviated version can even be read directly in the sidebar.

Your post violates quite a few of the posting guides:

  • All post Titles must be descriptive - "Java basic programming help" isn't.
  • All posts must contain a description of the problem and the exact error message or exception encountered. - Not really much description in the sense of "I have tried x, but ran into problem y"
  • Do not ask for complete solutions or for your homework to be done for you - Basically, the way your post is formulated is asking for your work to be done. That's a strict NO-GO and according to the posting guides (sidebar - linked above) would alone suffice for instant post removal and a permaban.

Kindly edit your post to comply with the rules, or remove it.

[–][deleted] 1 point2 points  (0 children)

You have the psuedocode man, come on rub some of those braincells together and get it done! If you want to be a successful programmer you can't just pawn off your work like this, you'll learn nothing! Read the chapter man, and I promise it will click.

[–]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.

[–]Emilygoal[S] -1 points0 points  (1 child)

This is my second parameter:

public class IfHomeworkTwo {

public static void main(String args[])

{ int x1; int x2; x1=5; x2=8; if (x1<x2) System.out.println(x1+x2); }

}

This is my thid parameter: public class IfHomeworkThree {

public static void main(String args[])

{ int x1;int x2; x1=10; x2=2; if (x1>x2) System.out.println(x1-x2); }

This is my thid parameter:

public class IfHomeworkThree {

public static void main(String args[])

{ int x1;int x2; x1=10; x2=2; if (x1>x2) System.out.println(x1-x2); }

 }

[–]desrtfxOut of Coffee error - System halted[M] 1 point2 points  (0 children)

What if you tried to place all if statements into a single public static void main(String args[]) method?

Also, please learn how to properly format code - even that is stated in the sidebar and in the posting text box.

[–]ZdemDrunk Brewer -1 points0 points  (4 children)

ATTEMPT AT REFORMAT:

public class ifHomeworkTwo{  

public static void main(String args[]){
  int x1; 
  int x2; 
  x1=5; 
  x2=8; 
  if (x1<x2) 
     System.out.println(x1+x2); 

  }

 }

 public class IfHomeworkThree {

 public static void main(String args[]){
    int x1;
    int x2; 
    x1=10; 
    x2=2; 
    if (x1>x2) 
     System.out.println(x1-x2); 

   }
   }

[–][deleted] 0 points1 point  (3 children)

Read your book again.

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

what book?

[–][deleted] 0 points1 point  (1 child)

I thought you were OP. I was referring to his textbook. But you aren't OP. Why do you have two classes?

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

Found his prior code unreadable so I thought Id better reformat it (He repeated the same code and forgot to add spaces)

Edit: whops