Hello there
Can anyone lend me a hand with this question? i'm seriously not looking for anyone to solve it for me, just a simple explaination will do. I'm having trouble knowing where to start, im just a beginner and this question really caught me by surprise, I don't even know what ceil and truncate are (I looked them up though).
Write programs to compute the following: YOU ARE ONLY ALLOWED TO USE +, -, /, *, %, MATH.floor and Math.Pow. Any other method in Math class should not be used.
- Ceil(x) ---> closest positive number 1.2 ---> 2
- Max (x,y,z) ---> given three numbers, return the largest.
- Min (x,y,z) ---> given three numbers, return the smallest
- Truncate(x)---> truncate the fraction of a real number 1.3 --->1
- Round(x)---> round the numbers 1.4 ---> 1, 1.6 ---> 2
- Absolute(x)
- rightmost(x,n)---> return the n right most digits of x , x=13,n=1 --->3, x=2432342,n=2, --->42
if x has a fraction, ignore the fraction x=1326.4,n=3 --->326
All x,y, z are to be read from the keyboard.
ideas, anyone? so far all I could do is this
import java.util.*;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.print("Enter x:");
double x = input.nextDouble();
System.out.print("Enter x:");
double y = input.nextDouble();
System.out.print("Enter x:");
double z = input.nextDouble();
}
}