Asked by Jake
How would I put this into one program?
These are the directions:
Write a method that takes two parameters. If the first parameter is equal to second parameter. Multiply both and print result.
If the first parameter is less than the second parameter, add the two and print the result 10 times.
If the first parameter is greater than the second parameter, subtract the first parameter from the second.
This is what I've got:
public class IfHomework {
public static void ifHomework(int first, int second)
{
System.out.println("first = " + first + " second = " + second);
System.out.println(first*second);
System.out.println(first+second);
System.out.println(second-first);
}
public static void main(String [] args){
int firstNumber =4;
int secondNumber =6;
{
ifHomework(firstNumber, secondNumber);
int x = 12;
int y = 12;
(x, y);
}
}
}
I'm new tho this I'm not sure what to do.
These are the directions:
Write a method that takes two parameters. If the first parameter is equal to second parameter. Multiply both and print result.
If the first parameter is less than the second parameter, add the two and print the result 10 times.
If the first parameter is greater than the second parameter, subtract the first parameter from the second.
This is what I've got:
public class IfHomework {
public static void ifHomework(int first, int second)
{
System.out.println("first = " + first + " second = " + second);
System.out.println(first*second);
System.out.println(first+second);
System.out.println(second-first);
}
public static void main(String [] args){
int firstNumber =4;
int secondNumber =6;
{
ifHomework(firstNumber, secondNumber);
int x = 12;
int y = 12;
(x, y);
}
}
}
I'm new tho this I'm not sure what to do.
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.