Can anyone tell me what the problem with my code here?? It is a simple java program that calculate the sum of 2 rational numbers
import java.util.Scanner; public class Exercise5 { static public void main(String[] args){ Scanner input = new Scanner(System.in); int a, x, b, y; double result=0; System.out.print("Please enter the numerator for the 1st rational number: "); a = input.nextInt(); System.out.print("Please enter the demonator for the 1st rational number: "); x = input.nextInt(); System.out.print("Please enter the numerator for the 1nd rational number: "); b = input.nextInt(); System.out.print("Please enter the demonator for the 1nd rational number: "); y = input.nextInt(); if (x==0 || y==0){ System.out.println("invalid input as the demonator cannot be Zero"); } else { result = ((a*y)+(b*x))/(x*y); System.out.printf("the result is: ",result); } input.close(); } }