/*
* Write Java code to execute the following fraction,
* if a = 3 , b = 5, c = 6, d = 4 (declare these as int type variables).
* numerator = a * b / (d + c)
* denominator = c % d - b + a
* results = numerator/denominator.
* output 'results'
*/
int a = 3;
int b = 5;
int c = 6;
int d = 4;
double numerator = ((float)a * (float)b / ((float) d + (float) c));
double denominator = ((float)c % (float)d - (float)b + (float) a);
double results = numerator / denominator;
System.out.println("Results: " + results);
/* Expected output should be -0.1666666716337204
* Show your hand calculation to verify correctness of 'results'.
*/
The comments are the goal of the project. I have to make a simple program that take's those numbers and puts it into the formula (as shown). However, I can't seem to get the number to match exactly with the expected output. This assignment was giving the day we learned about "Casting" in Java. So I assume it's something to do with that. I've gotten as close as -.1666666666666667. Is it something simple i'm looking over?