All pastes #386342 Raw Edit

t1

public java v1 · immutable
·published 2007-03-08 15:15 UTC
rendered paste body
public static void main (String[] args)    {                // PRINT OUT IDENTIFICATION INFORMATION                                System.out.println();        System.out.println("ITI 1120 Fall 2006, Assignment X, Question XX");        System.out.println("Name: Mike Kelly, Student# 4676728");        System.out.println("Name: Arul Bhaskar, Student# 3624411");        System.out.println();                component_validation();        System.out.println(CircuitComp[0]);    }             // If the 'main' method calls other algorithms, put the method(s) below.    /**     * This will ask the user to input values for the components of the circuit and then validate them.     */        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 (N < 4) {          System.out.println("Four values are needed.");          System.out.println(".3Please 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;                 }            }                /*System.out.println("Voltage: " + CircuitComp[0]);        System.out.println("Resistance: " + CircuitComp[1]);        System.out.println("Inductance: " + CircuitComp[2]);        System.out.println("Capacitance: " + CircuitComp[3]);*/        return CircuitComp;          }}