Need help on a while loop

Hi...I am somewhat new to Java and I am trying to do a nested while loop. Basically I have a result set from a query and I want to loop though that result set BUT I need a second loop to put together 150 of the results at a time and add them to a GeoCodeRequest to send to MapInfo.....this is how I think the code should look, I need some advice if it is the proper way to loop through....
ArrayList aal = new ArrayList();
ServiceMessage sm = new ServiceMessage();
ServiceMessage rsm = new ServiceMessage();
while (rset.next())
statRecord = statRecord + currentRecord;
while (rset.next() && currentRecord <= 150)
AddressEx a = new AddressEx(rset.getString(6));
ContentColumn cc = new ContentColumn("mmhid");
cc.setValue(rset.getString(1));
StreetAddress streetAddress = new StreetAddress(rset.getString(3));
streetAddress.setBuildingName(rset.getString(2));
a.setCountrySubdivision(rset.getString(5));
a.setMunicipality(rset.getString(4));
a.setPostalCode(rset.getString(6));
a.setContentColumn(0,cc);
aal.add(a);
currentRecord++;
System.out.println("Inside inner while loop now..");
System.out.println("Add 150 to request...");
GeocodeRequestEx gr = new GeocodeRequestEx("","3.0","id",(AddressEx[])aal.toArray());
gr.setGeocodePreference(pref);
sm.addRequest(gr);
System.out.println("going to geocode now...");
try{
LocationUtilityServiceLocator lus = new LocationUtilityServiceLocator();
LocationUtility lu = lus.getLocationUtility(new URL(url));
XLSType xr = lu.perform(sm.toXLS());
rsm = new ServiceMessage(xr);......
code goes on to do oter things but this is the basis..............
I hope that all made since.....please help.

I am not sure if there is a problem, that is what I am
asking......if I have the logic correct.
I haven't been able to test it correct because I am
getting an:
Exception in thread "main"
java.lang.ClassCastException: [Ljava.lang.Object; at
geoClient.main(geoClient.java:127)
That means you don't have it correct.  :-)> on the following line:> > GeocodeRequestEx gr = new> GeocodeRequestEx("","3.0","id",(AddressEx[)aal.toArray
and I haven't figured out to correct that yet......You need to use toArray(Object[]).

Similar Messages

  • Need help in creating for loop

    Hi,
    I want to create two different Xquery transformation by checking attribute value in the input xml.
    <n:DIAMessage xsi:schemaLocation="http://pearson.com/DIA C:/shashi/rewrite/DIA/DIA_Schemas/DIA_new.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n="http://pearson.com/DIA">
    <n:Customer>
    <n:Account sourceClassName="Account" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountRelation sourceClassName="AccountRelation" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountPerson name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR"/>
    </n:hasAccountRelation>
    </n:Account>
    <n:Account sourceClassName="Account" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountRelation sourceClassName="AccountRelation" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountPerson name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR"/>
    </n:hasAccountRelation>
    </n:Account>
    <n:Person name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:hasIdentifier sourceClassName="Identifier" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:IDType>GENDER</n:IDType>
    <n:IDTypeName>GENDER</n:IDTypeName>
    <n:IDValue>M</n:IDValue>
    </n:hasIdentifier>
    </n:Person>
    <n:Person name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:hasIdentifier sourceClassName="Identifier" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:IDType>GENDER</n:IDType>
    <n:IDTypeName>GENDER</n:IDTypeName>
    <n:IDValue>M</n:IDValue>
    </n:hasIdentifier>
    </n:Person>
    </n:Customer>
    </n:DIAMessage>
    From the above Message i need to create two transformation by checking
    if (DIAMessage/Customer/Account/@sourceClassName="Account")
    then call {
    Xquery1
    if(DIAMessage/Customer/Person/@sourceClassName="Person")
    then call{
    Xquery2
    Constraint here is Account and Person block occurence will be many times.As they are in same hierarchy how to create a for loop concept here?
    Please anyone can help me on this?

    Hi,
    Create a numeric variable to act as While loop counter and assign value of 1. Create a boolean variable to act as a flag to exit loop and assign value of true.
    Create a while object with a condition that while flag variable is true loop.
    Then you can create a switch with a case for each of your scenarios, referencing the xth record (defined by loop counter variable) in xml using ora:getElement
    When the count of required elements in input xml is less than your loop variable, assign the variable to exit loop as false...otherwise increment counter by one to loop to next record.
    Hope this helps.

  • Beginner needs help, simple do-while

    Need some help whit this code, how can I get this do-while loop to work?
    I use a simple gui where a decimal number is been read in, and some calculations beeing done.
    I want the user to decide if he/she wants to exit or not.
    But I dont now how I shall use it when using the boolean type.
    Tanks in advance.
    I'm sorry about my bad english!
    import mittBibliotek.*;
    class nettopris{
         static final double moms = 1.24;
         static final double rabatt = .85;
         public static void main (String[] args){
              do{
                   JavabokGUI gui = new JavabokGUI("Legger til moms");
                   gui.show();
                   double pris = gui.lesDesimaltall("","Skriv inn nettopris: ");
                   if (pris>2000){
                        double rabattPris=bergenNypris(pris);
                        double brutto = beregnBruttopris(rabattPris);
                        double rabattbel?p= beregnRabbattBel?p(pris,rabattPris);
                        gui.skrivResultater("Nettopris - 15% rabatt : " +rabattPris);
                        gui.skrivResultater("Prisen inkl. mva : " +brutto);
                        gui.skrivResultater("Rabatt bel?pet er : " +rabattbel?p);
                        gui.skrivResultater("Mva bel?pet er : "+beregnMvabel?p(brutto,rabattPris));
                   }else{
                        double brutto= beregnBruttopris(pris);
                        double avrundetPris= avrunding(brutto);
                        gui.skrivResultater("Prisen inkl mva (avrundet): " +avrundetPris);
                        gui.skrivResultater("Mva bel?pet er (avrundet): " +beregnMvabel?p(avrundetPris,pris));
                   }// end if else
                   boolean svar = gui.jaSvar("","Ny beregning? ");// GUI  yes/no.Where yes is true.If true looping until false
    }while  (svar == true) ;// error: cannot resolve symbol, variabel svar
         }// main
         static double beregnBruttopris(double prisen){
              double brutto= prisen * moms;
              return brutto;
         }//Brutto
         static double avrunding(double bruttopris){
              int avrundet= (int) (bruttopris + 0.5);
              return avrundet;
         }// Avrundet
         static double bergenNypris(double nyprisen){
              nyprisen = nyprisen * rabatt;
              return nyprisen;
         }// Nyprisen
         static double beregnRabbattBel?p(double pris, double rabatt){
              double rabbel?p = pris - rabatt;
              return rabbel?p;
         }// Rabatt bel?p
         static double beregnMvabel?p(double brutton, double rabattPrisen){
              double mvaBel?p = brutton - rabattPrisen;
              return mvaBel?p;
         }// Mvabel?p
    } // class nettopris

    If your only problem is with the variable svar, just put a line:
    boolean svar = true;before the "do" line and change the line:
    boolean svar = gui.jaSvar("","Ny beregning? ");to:
    svar = gui.jaSvar("","Ny beregning? ");Your problem has to do with variable scope. Since you declare the variable svar inside the braces {} of the do loop, it doesn't exist for the while test.

  • Need help with a For loop that uses a Break statement

    I need to create a for loop which counts down from 100-50 and divides the number being counted down by a counter. Can anyone help me?
    public class Break
    public static void main ( String args []) (;
         int total = 0
         int counter = 0
         for { (int number = 100; total >=50; total --)
         if (counter == 0)
         break;
         } // end of for loop
         int output = number/counter
         system.out.printf("The number is" %d output/n)
         }// end of method main
    }// end of class Break

    Im sorry I didnt explain myself very well i do not need the break statement at all.
    I now have this code:
    public class BreakTest
       public static void main( String args[] )
          int count; // control variable also used after loop terminates
         for (int i = 100; i >= 50; i = ++count)
       if (i >= 50) {
        continue;
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
       } // end main
    } // end class BreakTest
    /code]
    and i get these error messages:
    F:\csc148>javac BreakTest.java
    BreakTest.java:9: variable count might not have been initialized
         for (int i = 100; i >= 50; i = ++count)
                                          ^
    BreakTest.java:15: variable count might not have been initialized
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
                                                                    ^
    2 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help with a while loop condition

    I'm trying to write to a File. I ask the user for input, then I enter a while loop and test the condition. The loop works, but it won't stop. I've tried everything. Here is my code please help!!
    thanks
    inputline = keyboard.readLine();//read the keyboard
    try{
    while( inputline != null ){
    DiskOut.println( inputline );
    DiskOut.flush();
    inputline = keyboard.readLine();//read the keyboard again
    }//end while
    }//end try
    catch (IOException e) { 
    e.printStackTrace();
    }//end catch
    also i've tried these while loop conditions:
    while(inputline != "\n" || inputline != "\r") and the sort

    while(inputline != "\n" || inputline != "\r")The condition
    X!=Y OR X!=Z (given Y != Z)
    is always true. X will always not be equal to at least one of the values. So you'll want to use:
    while(!inputline.equals("\n") && !inputline.equals("\r"))In other words, "while inputline is not equal to either of them". Note the use of && instead of ||.
    If "keyboard" is simply a BufferedReader on top of System.in (and not your own class), the trailing line feeds and carriage returns won't even be in the string returned by readLine(). Your best bet is this:
    while(null != inputline && 0 != inputline.length())Make sure you type the two parts of that AND condition in the order above. If for whatever reason there are trailing \r and \n on the strings, you'll want to accomodate for platforms that may include both characters.
    // trim the trailing newline characters
    while(inputline.endsWith("\r") ||
          inputline.endsWith("\n")) {
       inputline = inputline.substring(0,inputline.length()-1);
    // or maybe this will work if you don't mind losing
    //  the whitespace at the beginning of the string:
    inputline = inputline.trim();Hope that helps somewhat.

  • Need help with an infinite loop please

    Can somebody please help me out with displaying text that's been imported from another file onto a JTextArea? this is the code i've been trying to get to work, and it does, but it is stuck in an infinite loop and i can't see why. I've tried adding a counter before the while loop, and displaying and incrementing it inside the loop. The counter gets to 32 (the last line of the file) then goes back to 1 and starts again. Any help, or explanations would be awesome, thanks.
    String line;
         while ((line=reader.readLine())!=null){
              System.out.println(num);
              append(line+" \n");
         }                              

    think you will have to post some more of the code, is that within any sort of loop itself , has it its own method ? is it an event handler ? ..btw the append sould be fine .. is this a subclass of a TextArea ? where is this bit of code ?
    Message was edited by:
    odd_function

  • Need help with the for loop

    Hello,
    I hope someone can point me in the right direction for my next assignment. I am very new at Java programming. For my next assignment for class I will need expand my previous program which was a mortgage calculator. The first assignment we wrote a program to show the monthly payments of a $200,000 loan at 5.75% for 30 years. Now we have to output all 360 monthly payments with pauses in between so it doesnt scoll off the page. The calculation that we use is:
    month_payments = (principle * monthlyinterest) / (1-Math.pow(1 + monthlyinterest, - months));
    My question is how do I get the correct calculation outputed 360 times. I would like to use the "for loop" to do this. Also what is the correct way to do the pause command? I do not want someone to write the code, I just want some help to where I need to start off, I want to learn this on my own.
    Thanks in advance,
    DC

    for (int i ; i < 10 ; i ++ ) { System.out.println("Come sail away"); }
    or;
    int i = 0;
    while(i < 10)
        i++;
        System.out.println("Come sail away");
    }

  • Help with Do/While Loops

    The user enters a number between 1&15 and the system gives 1 up unitl that number, if a person enters a number that is less than 1 and greater than 15 I want the system to say, "Must Enter number between 1 & 15" then exit. My program just ignores the fact that I put in ex. 17 and treats it like it was 15, ANy help is appreciated
    import java.io.*;
    public class Nik
    public static void main(String args[])
    BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
    try
    //declare variables
    String line;
    int i;
    boolean selection = true;
    boolean wrong = false;
    while (selection)
    System.out.print("Enter a number between 1 and 15:");
    line = keyboard.readLine();
    try
    i = Integer.parseInt(line);
    for (int j=1; j<15; j++) System.out.print(j+" ");
    System.out.println("");
    catch(NumberFormatException e){selection = false;}
    do
    System.out.println("You Must enter a number between 1 and 15:");
    try
    for (int j=0; j>16; j++)System.out.print(j+"");
    System.out.println("");
    catch(NumberFormatException e) {wrong=true;}
    }while(wrong);
    }catch(IOException e){}

    Your code doesn't check if the number is greater than 15 or less than 1. The loop seems a bit weird to me, this is how I would do it:
    import java.io.*;
    public class Nik
        public static void main(String args[])
            BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
            String line = "";
            boolean isValid = false;
            do
                System.out.println("Enter a number between 1 and 15:");
                try
                    line = keyboard.readLine();
                } catch(IOException e) {}
                int yourInt = Integer.parseInt(line);
                if(yourInt > 0 && yourInt < 16)
                    for(int j = 1; j < yourInt; j++)
                        System.out.print(j + " ");
                    System.out.println();
                    isValid = true;
                else
                    isValid = false;
            } while(isValid);
            System.out.println("Must Enter number between 1 & 15");
    }The most important part you were missing was:
    if(yourInt > 0 && yourInt < 16)but also I don't think you need 2 loops to do this.

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • Need help with a java loop and word program

    do you know any way to get a Scanner object to select a random string in a text file?
    ok pretty much I have a text file that isa list of 5 letter words. I need to select one at random.
    the only way I could think was to scan the file, get the entire nu of words, have Math.random choose a random nu then loop scanner.next() and have the loop condition run the Math.random amount of times
    but... when I do that I CANT ACCESS THE WORD OUTSIDE THE STUPID LOOP grrr...
    i'm annoyed lol
    this is the loop code that selects the random word
    int random = (int) Math.random() * numberOfWordsInFile + 1;
    int chooseLoopCount = 0;
    while (random >= chooseLoopCount)
    String theWord = scan.next();
    theWord = theWord.toLowerCase();
    chooseLoopCount += 1;
    see it's assigned properly to be the output of the scanner in all lower case letters, but outside the loop, the variable doesn't even exist
    anyway any suggestions would be awesome. thx

    String theWord = null;
    while (...)
      // set theWord in the loop
    // access to theWord is now available here, as it is in scope.
    // bear in mind if your loop didn't get executed, theWord is still null

  • Need help with a for loop

    Hi all
    I have a dir that has a list of folders that are created using php that my customers upload to. the PHP creates a new folder using the system date on the days that they upload. (using this format yyyymmdd)
    What I am trying to do is loop thou the folders and get todays folder and list the files that are in todays folder. I have been able to do this up to the point of if a customer folder does not have a folder called todays date.
    I know I need some sort of try / catch but don't know what.
    Can anyone help me please
    Thanks for you time and help in advance
    Craig
      public void getfolderList() {
        File dir = new File("/Users/craig/Documents/jBuilder_Epod/copy");
        File[] getFolderNames = dir.listFiles();
        if (getFolderNames != null) {
          for (int gf = 0; gf < getFolderNames.length; gf++) {
            String store = "" + getFolderNames[gf];
            if (!store.endsWith(".DS_Store")) { // This is a mac file name Only
              String folderName = "" + getFolderNames[gf];
              if (!store.endsWith(".DS_Store")) { // This is a mac file name Only
                //I need to have some sort of try and Catch here.
                // If there is no Folder called "todaysFileName" I need to go to the next folder
                //i.e. stop the for loop and go to next
                String setTodaysFileName = folderName + "/";
                String todaysFileName = setTodaysFileName + systemDate;
                File todaysFolder = new File(todaysFileName);
                File[] todaysFiles = todaysFolder.listFiles();
                for (int td = 0; td < todaysFiles.length; td++) {
                  todaysFileName = "" + todaysFiles[td];
                  System.out.println("There is no folder Today........" +
                                     todaysFileName);
      }

    A quick guess would be that after the sStatement
      File[] todaysFiles = todaysFolder.listFiles();todaysFiles is null if todaysFolder doesn't exist and you get a NullPointerException when trying to access todaysFiles.length in the following for-loop.
    If that doesn't help, please be a bit more precise what kind of Exception occurs...

  • Need help with basic "for" loops!

    Here is my prompt for class:
    Write a program that prompts the user to enter a sentence from the keyboard using JOptionPane.showInputDialog.
    The program will print the characters back with the first letter of each word changed from lower case into upper case. If you have a capital letter in the original line and it is not the first letter of a word, then this letter should be switched from upper case to lower case. The only capital letters that should appear in the line must be the beginning letter of every word in the line. All other characters will remain the same.
    I figured everything out except for one part. How do I make the first letter of each word change from lower case into uppercase? How do I switch a letter that is uppercase in the middle of a word to lowercase? Last but not least, how do I make sure that the only capital letters in the sentence are the first letter of each word?
    I need to do this using for Loops, charAt(), and if/else statements because this is just an intro class. I just can't figure this last part out! Help please!

    String words = ...;
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < words.length; i++) {
    char c = words.charAt(i);
    boolean isUpper = Character.?(look up the methods in java.lang.Character)
    boolean isLetter = ? (there are actually 2 ways to do this. Hint: you can use <= and >= and && to solve this)
    if (!isLetter) {
    continue;
    } else {
    // check if this is the start of the word. How do you know that you are at the start of a word?
    if (!isUpper && isStartOfTheWord) c = Character.toUpperCase(c); //Hint: there is a way you can do this with x + y
    else if (isUpper) //make c lower case
    builder.append(c);
    return builder.toString();

  • I need help with this while() statement please!

    So I'm pretty new to Java programming and I cannot seem to understand why this is not looping if the user inputs a "n" at the end.
    Here is my code:
    * proj1nrh.java
    * Created on September 28, 2007, 2:42 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package proj1nrh;
    * @author Nate
    import java.util.Scanner;
    public class proj1nrh {
    /** Creates a new instance of proj1nrh */
    public proj1nrh() {
    public static void main(String[] args) {
    String areYouFinished;
    char repeat;
    Scanner keyboard = new Scanner (System.in);
    int numericResponse1,
    numericResponse2,
    numericResponse3,
    numericResponse4,
    numericResponse5,
    numericResponse6,
    numericResponse7;
    System.out.println("Survey #1");
    System.out.println("Please enther the numerical student responses (1-5) for each question:");
    System.out.println("Q1. The instructor was available for consultation.");
    numericResponse1 = keyboard.nextInt ();
    System.out.println("Q2. Student responsibilities for this course were well defined.");
    numericResponse2 = keyboard.nextInt ();
    System.out.println("Q3. Class time well spent.");
    numericResponse3 = keyboard.nextInt ();
    System.out.println("Q4. I learned a lot from the intructor in this course.");
    numericResponse4 = keyboard.nextInt ();
    System.out.println("Q5. Course material contributed to my learning.");
    numericResponse5 = keyboard.nextInt ();
    System.out.println("Q6. I was challenged in this course.");
    numericResponse6 = keyboard.nextInt ();
    System.out.println("Q7. Coming into this course, I was motivated to learn this subject.");
    numericResponse7 = keyboard.nextInt ();
    //Consume new line
    keyboard.nextLine();
    System.out.println("Are you finished (y/n)?");
    areYouFinished = keyboard.nextLine();
    repeat = areYouFinished.charAt(0);
    } while (repeat == 'n' || repeat == 'N');
    Thanks for the help!

    Ight you guys have been great help.... but I'm having another problem
    * proj1nrh.java
    * Created on September 28, 2007, 2:42 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package proj1nrh;
    * @author Nate
    import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
    import java.util.Scanner;
    import java.util.ArrayList;
    public class proj1nrh {
        /** Creates a new instance of proj1nrh */
        public proj1nrh() {
        public static void main(String[] args) {
            String areYouFinished;
            char repeat;
            int n = 0;
            Scanner keyboard = new Scanner (System.in);
            int numericResponse1, sumOfResponse1,
                    numericResponse2, sumOfResponse2,
                    numericResponse3, sumOfResponse3,
                    numericResponse4, sumOfResponse4,
                    numericResponse5, sumOfResponse5,
                    numericResponse6, sumOfResponse6,
                    numericResponse7, sumOfResponse7;
            ArrayList storeValue1 = new ArrayList ();
            ArrayList storeValue2 = new ArrayList ();
            ArrayList storeValue3 = new ArrayList ();
            ArrayList storeValue4 = new ArrayList ();
            ArrayList storeValue5 = new ArrayList ();
            ArrayList storeValue6 = new ArrayList ();
            ArrayList storeValue7 = new ArrayList ();
          do {
                n = n + 1;
          System.out.println("Survey #1");
          System.out.println("Please enther the numerical student responses (1-5) for each question:");
          System.out.println("Q1. The instructor was available for consultation.");
            numericResponse1 = keyboard.nextInt ();
            storeValue1.add(numericResponse1);
            System.out.println("Q2. Student responsibilities for this course were well defined.");
            numericResponse2 = keyboard.nextInt ();
            storeValue2.add(numericResponse2);       
            System.out.println("Q3. Class time well spent.");
            numericResponse3 = keyboard.nextInt ();
            storeValue3.add(numericResponse3);
            System.out.println("Q4. I learned a lot from the intructor in this course.");
            numericResponse4 = keyboard.nextInt ();
            storeValue4.add(numericResponse4);
            System.out.println("Q5. Course material contributed to my learning.");
            numericResponse5 = keyboard.nextInt ();
            storeValue5.add(numericResponse5);
            System.out.println("Q6. I was challenged in this course.");
            numericResponse6 = keyboard.nextInt ();
            storeValue6.add(numericResponse6);
            System.out.println("Q7. Coming into this course, I was motivated to learn this subject.");
            numericResponse7 = keyboard.nextInt ();
            storeValue7.add(numericResponse7);
            //Consume new line
            keyboard.nextLine();
            System.out.println("Are you finished (y/n)?");
            areYouFinished = keyboard.nextLine();
            repeat = areYouFinished.charAt(0);
          } while (repeat == 'n' || repeat == 'N');
            int sum = 0;
    }I want to get the sum of each ArrayList 1-7 so I can divide this sum by "n" and display the average output.
    Thanks!

  • Need help regarding Issues while use T=0/T=1 Protocol

    Hi Friends..
    I developed an Simple Applet to be Personalized by Datacard Machine..
    This Applet is downloaded and installed in 2 difference protocol, (T=0 and T=1)..
    This is a little description of my Applet :
    CLA used is (byte) 0x80, otherwise SW 6E00 returned
    INS (byte) 0x20 : is used for Ingoing Command (To Send Data to Applet)
    INS (byte) 0x30 : is used for Outgoing Command (To Get Data From Applet)
    P1 = (byte) 0x00 : is used to Send Data and Get Data for field Employee code
    Case T=0 :*
    I tried to send this APDU through Datacard Machine :
    80 20 00 00 05 01 02 03 04 05 00
    the SW resulted is 90 00
    After that i tried to send this APDU through Datacard Machine :
    80 30 00 00 00
    There's no Response Data, and the SW resulted is 61 08
    But, if i try to Get Data using SmartCardIO, i can get Data as i want, and the SW is 90 00
    What is the meaning of SW 61 08?
    I think this SW tells me that there's 8 bytes remaining data (but i don't know whether this is correct)..
    But in the Case T=1 Protocol :*
    I did the same thing, and there's no error returned..
    i can Read an Write without any error..
    Please correct me if i'm wrong..
    Any help would be appreciated..
    Thanks
    Edited by: Leonardo Carreira on Oct 27, 2010 7:49 PM
    Edited by: Leonardo Carreira on Oct 28, 2010 6:22 PM
    Change the title

    Leonardo Carreira wrote:
    After that i tried to send this APDU through Datacard Machine :
    80 30 00 00 00
    There's no Response Data, and the SW resulted is 61 08
    But, if i try to Get Data using SmartCardIO, i can get Data as i want, and the SW is 90 00 The datacard machine may not handle the GET RESPONSE apdu for you. SmartcardIO does this transparently.
    What is the meaning of SW 61 08?SW '61XX' = SW2 encodes the number of data bytes still available. This is because you are using T=0.
    I think this SW tells me that there's 8 bytes remaining data (but i don't know whether this is correct)..That is correct
    But in the Case T=1 Protocol :*
    I did the same thing, and there's no error returned..
    i can Read an Write without any error..This is due to the differences between T=0 and T=1 protocols. T=1 will send you a response containing the data, T=0 will send you the numbder of bytes it expects to return and waits for a GET RESPONSE before sending you the data. As mentioned above, SmartcardIO handles this for you transparently while other libraries mat not (RAW PC/SC does not). You can read more about this in ISO7816-3
    Cheers,
    Shane

  • Help with do while loop

      This program that reads a character representing a geometrical
      figure, then asks the user to enter the required data (ex. Radius for
      a circle, length and height for a rectangle, etc.  ...) .
      The program should then print the area and circumference.   Figures are: circle(c), square(s), rectangle(R), triangle (t).
      The program should repeat until a figure with area <10 are read
       import javax.swing.JOptionPane; // program uses class JOptionPane
        public class Sh7q6
       // main method begins execution of Java application
           public static void main( String args[] )
             String outputStr; // The output string
             String str; // The entered characher
             char n; // The character entered
                   double a; // aera
             double radius; // the radius of a circle
             double area; // the area of a circle, square, rectangle, triangle
             double circumference; // the circumference of a circle
             double m; // The square side length
             double circumference1;  //  the total for a * a
             double length;  // the length of a rectangle
             double width;  // the width of a rectangle
             double circumference2;  //  the total for 2*(length + width)
             double base; // the base of a triangle
             double side1; // the first side of a triangle
             double side2; // the second of a triangle
             double hight;
             double circumference3;  //  the total for ( base + side1 + side2 )
             do
             // display the information in a JOptionPane message dialog
                str = JOptionPane.showInputDialog("Enter a character specifying a geometrical shape" +
                   "\n" + " Circle = c" + "\n" + "Rectangle = R" + "\n" + "Square = s" + "\n"
                   + "Triangle = t" );
                n = str.charAt(0); // return the caracter
                switch (n)
                   case 'c':
                   case 'C':
                   // convert String inputs to double values for use in a calculation
                      radius = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the radius of a circle:"));     
                      area = 3.14 * Math.pow ( radius, 2); // calculate the area      
                      circumference = 2 * 3.14 * radius;// calculate the circumference
                      outputStr = String.format("The area of a circle is: %.2f%n" +
                         "The circumference of a circle is: %.2f", area, circumference);
                   // display result in a JOptionPane message dialog
                      JOptionPane.showMessageDialog(null, outputStr , "The result",
                         JOptionPane.INFORMATION_MESSAGE);
                      break;
                   case 's':
                   case 'S':
                   // convert String inputs to double values for use in a calculation
                      m = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the square side length:"));     
                      area = Math.pow ( m, 2); // calculate the area         
                      circumference1 = 4 * m;// calculate the circumference
                      outputStr = String.format("The area of a square is: %.2f%n" +
                         "The perimeter of a square is: %.2f", area, circumference1);
                   // display result in a JOptionPane message dialog
                      JOptionPane.showMessageDialog(null, outputStr , "The result",
                         JOptionPane.INFORMATION_MESSAGE);
                      break;
                   case 'r':
                   case 'R':
                   // convert String inputs to double values for use in a calculation
                      length = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the length of a rectangle:"));
                      width = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the width of a rectangle:"));     
                      area = length * width ; // calculate the area     
                      circumference2 = 2* (length + width); // calculate the circumference
                      outputStr = String.format("The area of a square is: %.2f%n" +
                         "The perimeter of a square is: %.2f", area, circumference2);
                   // display result in a JOptionPane message dialog
                      JOptionPane.showMessageDialog(null, outputStr , "The result",
                         JOptionPane.INFORMATION_MESSAGE);
                      break;
                   case 't':
                   case 'T':
                   // convert String inputs to double values for use in a calculation
                      base = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the base of a triangle:"));
                      side1 = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the first side of a triangle:"));
                      side2 = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the second side of a triangle:"));
                      hight = Double.parseDouble(
                         JOptionPane.showInputDialog("Enter the hight of a triangle:"));     
                      area = 0.5 * base * hight; // calculate the area      
                      circumference3 = base + side1 + side2;// calculate the circumference
                      outputStr = String.format("The area of a triangle is: %.2f%n" +
                         "The circumference of a yriangle is: %.2f", area, circumference3);
                   // display result in a JOptionPane message dialog
                      JOptionPane.showMessageDialog(null, outputStr , "The result",
                         JOptionPane.INFORMATION_MESSAGE);
                      break;
                   default:
                   // display result in a JOptionPane message dialog
                      JOptionPane.showMessageDialog(null, " The letter you entered doesn't " +
                         "represent either a circle or a rectangle or a square" , "ERROR",
                         JOptionPane.ERROR_MESSAGE);
             while (  area > 10 );
             System.exit(0);
          } // end method main
       } // end class Sh7q6the Q is how can i say when the area < 10 stop the loop in the while logical expression..

    the Q is how can i say when the area < 10 stop the loop in the while logical expression..You're almost already doing that. You're doing this:
             while (  area > 10 );As soon as the area is 10 or below, that expression will evaluate to false and the loop will end.
    If you want to still loop when the value is 10, then change it to:
             while (  area >= 10 );

Maybe you are looking for

  • How to change name of uploaded file

    I am using the a multi-part form and the pl/sql gateway to enable users to upload files to portal. The files automatically get stored in the wwdoc_document$ table. The key to the file is a column called "name" which consists of a sequence number and

  • Get parent of Embedded message

    Hello all. I have a message with the following structure: Message multipart-1 gif1 embedded message (Content-Type: message/rfc822) multipart-2 text gif2 I have the gif2 body part in my hand, and I want to get the message-id header of the outer messag

  • How can i use iphone 6 in other country ?

    I want buy a IPhone 6 and use it in other country's, like in Africa. 

  • Job schedule: How to process huge ammount of IDocs ?

    HI, we´got a huge ammount (1000-5000 IDocs) of one IDoctype. I need a Job with a maximum of 40 IDocs in each job. The job looks like: 1. Step RBDAPP01 with 40 IDocs 2. Step own report Is there any way not to create a new variant for each "40 IDoc gro

  • Call record

    how can we record all contact numbers we have called, received in iPhone 4S, with ios 7