This is what Im gonna do:
In a class called UsefulMethods :
a) Write a method public static int maxOfTwo( int tal1, int tal2) {} . As you can see this method
will accept two integers as parameters and returns the larger of this two.
This one I rly need help with, here is where im stuckb) In another class called TestUsefulMethods, write a main program and test your maxOfTwo ().
To do it , first read two values from the user ( Sanner object required) and then call maxOfTwo
method with the two values. The programme shoul print the return from this method.
c) Go back to UsefulMethods class and write a new method. This method will also be static, and
the name should be evenlyDivisible. The method will accept two integers as parameters and
return true if the first parameter is evenly divisible by the second or vice versa and false if not.
d) Test your method by calling it in your programe TestUsefulMethods. Print the result from the
method.
The first one I have done like this:
public class UsefulMethods
{
public static int maxOfTwo(int tal1, int tal2)
{
if(tal1>tal2)
return tal1;
else
return tal2;
}
}
So now my problem is to use this in:
This is what I have com up with atm.
import java.util.*;
public class TestUsefulMethods
{
public static void main (String[] args)
{
UsefulMethods m =new UsefulMethods();
int tal1;
int tal2;
Scanner scan=new Scanner(System.in);
tal1=scan.nextInt();
tal2=scan.nextInt();
System.out.println ("Highest number is: ");
}
}