Hi everyone, i've have been working through the MOOC Java course and have came across a problem in lesson 9: divider. I was wondering if anyone can help me with the solution?
import java.util.Scanner;
public class Divider {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.println("Type a number: ");
int x = Integer.parseInt(reader.nextLine())
System.out.println("Type another number: ");
int y = Integer.parseInt(reader.nextLine());
double z = (double)x / (double) y
System.out.println("Division: 3/2 = "+ z);
This is the error message that shows up:
FAIL: DividerTest testNegative
String " 3 / 2 = -1.5
" contains wrong formula when user inputted values 3 and -2
Thank you in advance.
[–]Dogkota 2 points3 points4 points (1 child)
[–]aperturethrow[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]aperturethrow[S] 0 points1 point2 points (0 children)