0

HELP fix error function to read two double type numbers from keyboard. B)function to calculate division of these two numbers?

import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter two double"); double x=sc.nextDouble(); double y=sc.nextDouble(); System.out.println("Double: "+x); System.out.println("Double: "+y); } } public class Example { public static void main(String[] args) { Solution a=new Solution(); double p=a.x; double q=a.y; System.out.println(divisionFunction(p, q)); } public static int divisionFunction(double dividend, double divisor) { int quotient; if (divisor == 0.0) { throw new IllegalArgumentException("Argument 'divisor' is 0"); } else { return quotient = (int) (dividend / divisor); } } }

18th Oct 2020, 1:12 PM
Charlie Z
Charlie Z - avatar
1 Réponse
0
Unable to use x,y inputs in class example
18th Oct 2020, 1:12 PM
Charlie Z
Charlie Z - avatar