Question: JAVA-- Why is my output coming out as 0's? thank you The problem is the output is coming out as 0.0 every time which is
! D stickFigure.java D pointsandLines.java 23 D basicFractions.java D conditionsjava B1 import java.util.Scanner; 3 public class pointsandlines t .jar -/Libran brary/JavalJa public static void main(String[] args) Library/Java 6 ibrarylJaval 8 ar- /Library 9 brary/Java/J 10 /Library/Ja 11 getCoordinatesO); riseRunCe, 0, 0, ); xyMidpointC0, e, e, ); outputce, 8, e): double] temp xyMidpoint(1,2,3,4); double midpointX temp[0]; double midpointy temp[1] 14 Library/Java /Library/Ja' : 16 jar /Librar 17 vider.jar- 18 jar - /Libra 19 /Library/J 20 Library/Jav 21 jar -/Syste22 } public static void getCoordinatesO f System.out.println"Please enter your first x"); Scanner scan-new Scanner(System. in); double x1 scan.nextDoubleO System, out.println" Please enter your first y) double y1 -scan.nextDoubleO: System.out.println Please enter your second x") double x2 scan.nextDoubleO; System.out.println"Please enter your second y); douhle ?sean nextDouhle ar - /Librar 28 arylJava/Ja 29 /LibraryConsole 3 Library/Ja Please enter your first x ibrary/Java 30 rary/Javal.31 terminated> pointsandLines (Java Applicationl /Library/Java/JavavirtualMachinesjidk1.8.0 191. jdk/Contents/-Home/bin/java (Mar 5, 20 Libraryl2 Library Please enter your first y /Java1 Library/Ja Please enter your second x brary Please enter your second y der.jar - ar -/Libra Thank you. The equation of Cy2-y1)/Cx2-x1) will calculate your rise over run. Library Your midpoint is (0.0,0.0) ar- /Syste File Edit Source Refactor Navigate Search Project Run Window Help eclipse-workspace- dLines java pointsandLinesjava 23 M basicFractions java double y2 scan.nextDoubleO: conditionsjava stickFigure java 32 s.jar- /Librar 34 brary/JavaJa 35 Library/Java 36 ibrary/Java 37 ar - /Library 38 39 Library/Jar 41 public static double riseRun double x1, double x2, double y1, double yz) t System.out.printlnC"Thank you. The equation of braryJava/J + "(y2-y1)/(x2-x1) will calculate your rise over run. r-Libraryl 4 r-/Libraryl 43 Library/Java 4 double slopeResult (y2-yl)/(x2-x); Library/Ja 45 jar /Librar 46 47 return slopeResult vider,jar- 48 jar . /Libra Library/J 50 ibrary/Jav 51 jar -/Syste 52 53 54 public static doubleD3 xyMidpoint(double x1, double x2, double yl, double y2) t double midpointx - (x2-x1)/2; double midpoint (y2-y1)/2; 56 57 Librar 58 ry/Java/Ji59 rary/Java 60 ary/Java/. /Library Console X ry/Java/J ibrarylJar Please enter your first x Libraryl2 Library/ Please enter your first y ary Java 1 brary/Ja Please enter your second x Librar3 r.jar -/ double points new double[2]; points[0] midpointX; cterminated> pointsandLines [Java Application]/LibrarylJava/JavaVirtualMachines/jdk1.8.0.191.jdk/Contents/Home/bin/java (Ma Please enter your second y Libr Thank you. The equation of (y2-y1)/(x2-x1) will calculate your rise over run. brarylJ Your midpoint is (8.0,0.0) rylJav Your slope is 8. /Syste D stickFigure java D pointsandLines javaD basicFractions.java D conditions.java 48 49 50 ar 51e public static doubleD] xyMidpoint(double x1, double x2, double y1, double y2) f J 52 double midpointX -(x2-x1)/2; va 53 a/. 54 double midpointY (y2-y)/2 ILI 56 57 58 59 y60 a double points new double[2] points[e] midpointx; points[1]- midpointY; return points; 61 a62 ar 63 64 65 public static void output(double midpointx, double midpointY, double slopeResult) System.out.printlnC Your midpoint is ("midpointXmidpointY)"); System.out.printlnC Your slope is +slopeResult) 70 71 72 73 74 75 76 Console
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
