Write a method called compFloat5 which accepts as input two doubles as an argument (parameter). Write the appropriate code to test the two numbers up to five decimal points to see if they are close enough. If they are close enough return true else return false. This would be a Boolean value. f. Write a method called compInt which accepts as input two integers as an argument (parameter). Write the appropriate code to test the two integers to see if they are equal. If they are equal return true else return false. This would be a Boolean value. g. Write a method called stringEqual program that reads in two sentences as an argument (parameter). Write the appropriate code to test the two strings to see if they are the equal. If they are equal return true

Respuesta :

Answer:

public class Comparision {

public boolean compFloat5(double d1, double d2) {

// Rounding off to two decimal places

d1 = (Math.round(d1 * 100000) / 100000.00);

d2 = (Math.round(d2 * 100000) / 100000.00);

if (d1 == d2)

return true;

else

return false;

}

public boolean compInt(int int1, int int2) {

if (int1 == int2)

return true;

else

return false;

}

public boolean stringEqual(String s1, String s2) {  

if (s1.equals(s2))

return true;

else

return false;

}

public boolean stringCompare(String s1, String s2) {

int i = s1.compareTo(s2);

if (i == -1)

return true;

else  

return false;

}  

}