I've been programming for years in a basic programming language, so doing something a bit more advance like this is quite challenging but I love it. Could someone help me where I've gone wrong here? I've been following a tutorial but I've decided to take what I've learned and make my own program but something seems to be wrong.
class Function{ public double abs(int num) { if (num > -1) { return num; } else { return -num; } } public double distance(double aa, double bb) { return aa-bb; } } class Test { public static void main(String[] args) { double a = 1, b = 5; Function func = new Function(); double results; results = func.distance(a, b); results = func.abs(results); System.out.print(results); } }
Basically trying to get the distance between to numbers but in a positive not negative number. Thank you in advance.
- Nicky