0 LIKES LikeUnLike
This program is supposed to solve the distance formula. But when I compile it, an error called "operator^ cannot be applied to double,double Pops up. Why? I will give 10 points for the best answer.import java.lang.Math;import java.util.Scanner;class DistanceFormula { public static void main(String args[]) { Scanner myScanner = new Scanner(System.in); double x1; double x2; double y1; double y2; double distance; System.out.print("x1= "); x1 = myScanner.nextDouble(); System.out.print("x2= "); x2 = myScanner.nextDouble(); System.out.print("y1= "); y1 = myScanner.nextDouble(); System.out.print("y2= "); y2 = myScanner.nextDouble(); System.out.print("Distance= "); distance = Math.sqrt((x2-x1)^2+(y2-y1)^2); }}
Tags:
Report (0) (0) | earlier
Latest activity: earlier. This question has 3 answers.