All pastes #386335 Raw Edit

t1

public java v1 · immutable
·published 2007-03-08 15:04 UTC
rendered paste body
public static double[] component_validation()    {        //DATA DICTIONARY        double[] CircuitComp;        CircuitComp = new double[4];        System.out.println("Please enter reasonable values for each circuit component, in the following order: Voltage, Resistance, Inductance, Capacitance");        CircuitComp = ITI1120.readDoubleLine();        int N = CircuitComp.length;                //validate these values, using a loop that will iterate continuously until all values have been validated        //and only then will the program continue        int i = 1;        while (i != 0) {            N = CircuitComp.length;         //this next part basically says if there are ANY errors then find out specifically which error it is and ask the user to correct it         //this will continue until there are no errors, and the else statement will cause the loop to exit.          if(N > 4 || (!(5 <= CircuitComp[0] && CircuitComp[0] <= 15)) || (!(50 <= CircuitComp[1] && CircuitComp[1] <= 500)) || (!(0.001 <= CircuitComp[2] && CircuitComp[2] <= 0.1)) || (!(0.00001 <= CircuitComp[3] && CircuitComp[3] <= 0.0001))){        if (N > 4) {          System.out.println("Only four values are needed.");          System.out.println("Please enter reasonable values for each circuit component, in the following order: Voltage, Resistance, Inductance, Capacitance");          CircuitComp = ITI1120.readDoubleLine();        }        if (!(5 <= CircuitComp[0] && CircuitComp[0] <= 15)){          System.out.println("Your voltage value is not within reasonable limits.  Min. 5 volts and Max 15.");          System.out.println("Please enter reasonable values for each circuit component, in the following order: Voltage, Resistance, Inductance, Capacitance");          CircuitComp = ITI1120.readDoubleLine();        }        if (!(50 <= CircuitComp[1] && CircuitComp[1] <= 500)){          System.out.println("Your resistance value is not within reasonable limits.  Min. 50 ohms and Max 500.");          System.out.println("Please enter reasonable values for each circuit component, in the following order: Voltage, Resistance, Inductance, Capacitance");          CircuitComp = ITI1120.readDoubleLine();        }        if (!(0.001 <= CircuitComp[2] && CircuitComp[2] <= 0.1)){          System.out.println("Your inductance value is not within reasonable limits.  Min. 0.001 henrys and Max 0.1.");          System.out.println("Please enter reasonable values for each circuit component, in the following order: Voltage, Resistance, Inductance, Capacitance");          CircuitComp = ITI1120.readDoubleLine();        }        if (!(0.00001 <= CircuitComp[3] && CircuitComp[3] <= 0.0001)){          System.out.println("Your capacitance value is not within reasonable limits.  Min. 0.00001 farads and Max 0.0001.");          System.out.println("Please enter reasonable values for each circuit component, in the following order: Voltage, Resistance, Inductance, Capacitance");          CircuitComp = ITI1120.readDoubleLine();        }          }        else{         i = 0;                 }            }        return CircuitComp[];          }