Note that there are some explanatory texts on larger screens.

plurals
  1. POI need to figure out the logical bug in my Code
    primarykey
    data
    text
    <p>when I call the method "getUnknownsAccel" with the problem1 object, for some reason the 'if' statement in the method is not executed to retrieve the value of the variable:</p> <pre><code>PhysicsProblem problem1 = new PhysicsProblem(accel, vI, vF, t, deltaX); System.out.println("Which variable are you solving for? "); String solveFor = scan.next(); // after receiving solveFor input, assesses data accordingly if (solveFor.equalsIgnoreCase("acceleration")) { System.out.println("Solving for Acceleration!"); System.out.println("Are there any other unknowns? (enter 'none' or the name " + "of the variable)"); missingVar = scan.next(); problem1.setMissingVar(missingVar); do { problem1.getUnknownsAccel(); System.out.println("Are there any other unknowns? (enter 'none' or the name " + "of the variable)"); missingVar = scan.next(); //// change all these in the program to scan.next, not scan.nextLine } while (!missingVar.equalsIgnoreCase("none") || !missingVar.equalsIgnoreCase("acceleration")); if (missingVar.equals("none")) { // Write code for finding solutions System.out.println("Assuming you have given correct values, the solution is: "); } } </code></pre> <p>After the do/while loop used to retrieve the name of the other variables that are unknown, I call the getUnknownsAccel method from this class file:</p> <pre><code>public void getUnknownsAccel() { //----------- // checks for another unknown value that is not accel //----------- if (missingVar.equalsIgnoreCase("time")) { System.out.println("Please enter the value for time: "); t = scan.nextDouble(); while (t &lt;= 0 || !scan.hasNextDouble()) { System.out.println("That is not an acceptable value!"); t = scan.nextDouble(); } } } </code></pre> <p>Let's assume for the sake of this problem, that the user WILL enter "time" as the unknown when prompted. Any idea why my code isn't executing the scan function to retrieve the time variable value? Instead, the program just repeats the system.out function "Are there any other unknowns..."</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload