2021年3月29日星期一

beginner error using methods in java be respectful

ok so for a bit of context I am relatively new to coding and I was taking an online coding class in order to improve my skills on my own time and I'm stuck on this one problem and tips or tricks are greatly appreciated

the problem is how do you create a method that can sort through these rules a greater then 0 and b greater then 0 if a greater then b print A else print B else if B greater then 0 l l a greater then 0 print C else print D

the code i wrote is below

  public void conditionalTest(int a, int b)  {    if ((a > 0) && (b > 0))  {    if (a > b)    System.out.println("A");  else    System.out.println("B");  }  else if((b < 0) || (a < 0))    System.out.println("C");  else    System.out.println("D");  }  

i have went over my code and i cant find anything wrong with it but when i try to run it, it wont work

https://stackoverflow.com/questions/66864636/beginner-error-using-methods-in-java-be-respectful March 30, 2021 at 12:04PM

没有评论:

发表评论