How convert java FOR loop into  taglib directive

hi all,
I have following code in my Jsp. It is working but, we dont want to use java FOR loop anymore. Instead use corresponding taglib directive.
How can i convert this Java FOR loop into taglib implementation of FOR loop ?
               <%
               for(int i=0;i< arrMemberBenefit.length;i++)     {
                    pageContext.setAttribute("arrMemberBenefiti", arrMemberBenefit);
System.out.println("PCPNAME: " + arrMemberBenefit[0].getPcpName());
%>
                    <tr class="rowOdd">
                         <td headers="t1h1" class="first"><c:out value="${arrMemberBenefiti.member.firstName}${space}${arrMemberBenefiti.member.lastName}" /></td>
                         <td headers="t1h2" class="last"><c:out value="${arrMemberBenefiti.pcpName}" /></td>
                    </tr>
<%}
%>
pl any help highly apprecialted
pp

Using the JSTL forEach tag:
I have used your variable name for arrMemberBenefiti
myself I would probably call it something like memberBenefit
You may need to put the array into an attribute to begin with
// just in case
<% pageContext.setAttribute("arrMemberBenefit", arrMemberBenefit); %>
// and the actual JSTL loop
<c:forEach var="arrMemberBenefiti" items="${arrMemberBenefit}">
  <tr class="rowOdd">
    <td headers="t1h1" class="first"><c:out value="${arrMemberBenefiti.member.firstName}${space}${arrMemberBenefiti.member. lastName}" /></td>
    <td headers="t1h2" class="last"><c:out value="${arrMemberBenefiti.pcpName}" /></td>
  </tr>
</c:forEach>Cheers,
evnafets

Similar Messages

  • Please help me.. how to rewrite the following java- for loop code in ada

    int i, j, n = 100;
    for (i = 0, j = 17; i < n; i++, j-- )
    sum += i * j + 3;

    how to rewrite the following java- for loop code in ada
    You should have a programming manual for Ada first. If you mean it the other way round, I think you subject line confused me.

  • I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

    I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.

    I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.
    I can see that I should somehow save the indices of the positive X values from the large arrray wh
    en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.
    I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
    Attachments:
    Poling_Data_Reader_5i.vi ‏79 KB
    30BLEND.txt ‏3 KB

  • How to make for loop pass only once in a next() method

    Good Day!
    Can anyone help me or suggest any idea to resolve my problem with the below code, wherein it will only pass the for loop only once. I already tried inserting the for loop in side the if (sqlset4.isFirst()) condition but the problem is it only retrieved the first row of the resultset.
    Cheers!
                   Statement sOutput = consrc.createStatement();
                            ResultSet sqlset4 = sOutput.executeQuery(xquery);
                            ResultSetMetaData rsMetaData = sqlset4.getMetaData();
                            int numberOfColumns = rsMetaData.getColumnCount();
                            String writefld = "";
                            while (sqlset4.next()) {
                                 writefld = "";
                                 for (int i = 1; i <= numberOfColumns; i++) {
                                     if (xxformatid.equals("1") || xxformatid.equals("3")) {
                                         writefld = writefld + "sqlset4.getString(" + i + ").trim()" + "|";
                                writefld = writefld.substring(0, writefld.length() - 1) + ")";
                                output.write("\r\n");
                                output.write(writefld);
                            output.close();I am using Netbean IDE 6.8
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi

    Hi everyone!
    What I actually trying to do is that I have a multiple tables and from these tables I'm going to write each of it into a flatfile that is a pipe delimeted that is why I have to make a loop to know how many fields I am going to write. The code that was attached are actually working, my only concern is that it will take a longer time of processing cause every record of a table it will pass to the for loop(checking how many column) wherein number of column/ were already known on the first loop.
    Hi kajbj,
    I think what your trying to explain is almost the same with below code which i had already tried. The problem with this is that the every loop of the outer loop data retrieve is only the data of the first record.
                   Statement sOutput = consrc.createStatement();
                            ResultSet sqlset4 = sOutput.executeQuery(xquery);
                            ResultSetMetaData rsMetaData = sqlset4.getMetaData();
                            int numberOfColumns = rsMetaData.getColumnCount();
                            String writefld = "";
                            while (sqlset4.next()) {
                                 writefld = "";
                                 if (sqlset4.isFirst()) {
                                    for (int i = 1; i <= numberOfColumns; i++) {
                                        if (xxformatid.equals("1") || xxformatid.equals("3")) {
                                            writefld = writefld + "sqlset4.getString(" + i + ").trim()" + "|";
                                writefld = writefld.substring(0, writefld.length() - 1) ;
                                output.write("\r\n");
                                output.write(writefld);
                            output.close();

  • How to use for loops with Multiple Initializers and Incrementers

    I found that my for loop is printing out wrong, because I am using two for loops. I have searched but all I can find out is you can't use multiple inializers and increments, does anyone know how to get around this? How would I use an array for this?
    Thanks very much for your help.
    import java.util.Random;
    import java.util.Arrays;
    /** Generate numnodes value for random integers in the range 0..499. */
    public final class RandomInteger {
    public static final void main(String... aArgs){
    log("Generating 6 random integers in range 0..499.");
    int numnodes = 6;
    //Randomly generate a number between 0 and 499 for the x and y coordinates for the nodes
    Random randomGenerator = new Random();
    for (int x = 0; x < numnodes; ++x) {
    int randomInt = randomGenerator.nextInt(500);
    Random randomGenerator2 = new Random();
    for (int y = 0;y < numnodes; ++y) {
    int randomInt2 = randomGenerator2.nextInt(500);
    log("Generated : " + randomInt + " " + randomInt2);
    log("Done.");
    }

    Sorry that code works, but I want to use both my x and y coordinates to get a random number from 0 to 499 in both of them, then I want to do some comparisons of the values, then return it to another function. As it stands now, I get the wrong results when I run it, as you can see at the bottom.
    Thanks very much for your help. I have been stumped all mornign on this and have looked everywhere trying to find an example. I don't won't to use math random. I am on a tight deadline to finish and at the rate I am going, I will not complete it.
    /** Generate numnodes value for random integers in
    the range 0..499. */
    public final class RandomInteger {
    public static final void main(String... aArgs){
    log("Generating 6 random integers in range
    0..499.");
    int numnodes = 6;
    //Randomly generate a number between 0 and 499 for
    the x and y coordinates for the nodes
    Random randomGenerator = new Random();
    for (int x = 0; x < numnodes; ++x) {
    int randomInt = randomGenerator.nextInt(500);
    Random randomGenerator2 = new Random();
    for (int y = 0;y < numnodes; ++y) {
    int randomInt2 = randomGenerator2.nextInt(500);
    log("Generated : " + randomInt + " " + randomInt2);
    log("Done.");
    private static void log(String aMessage){
    System.out.println(aMessage);
    Output:
    --------------------Configuration:
    <Default>--------------------
    Generating 6 random integers in range 0..499.
    Generated : 98 254
    Generated : 98 347
    Generated : 98 359
    Generated : 98 25
    Generated : 98 277
    Generated : 98 148
    Generated : 416 401
    Generated : 416 165
    Generated : 416 354
    Generated : 416 169
    Generated : 416 144
    Generated : 416 354
    Generated : 295 158
    Generated : 295 138
    Generated : 295 349
    Generated : 295 324
    Generated : 295 18
    Generated : 295 193
    Generated : 197 451
    Generated : 197 416
    Generated : 197 480
    Generated : 197 33
    Generated : 197 490
    Generated : 197 494
    Generated : 324 412
    Generated : 324 490
    Generated : 324 213
    Generated : 324 386
    Generated : 324 467
    Generated : 324 163
    Generated : 379 180
    Generated : 379 446
    Generated : 379 314
    Generated : 379 52
    Generated : 379 113
    Generated : 379 271
    Done.
    Process completed.

  • How convert to jpg picture into bmp ?

    Hi experts,
    I am trying to convert my jpg picture into bmp. for this i write one report but showing some
    TRANSFER WA_MIME1 TO DSN1.
    HERE IS MY FULL CODE PLZ HELP ME.
    REPORT  ZSE78_7.
    DATA: blob TYPE w3mimetabtype,
           blob_size TYPE w3param-cont_len,
           blob_type TYPE w3param-cont_type  .
    DATA:
         p_color_scheme      TYPE char20  ,
         p_labels_groupid    TYPE igs_label_tab,
         p_labels_category   TYPE igs_label_tab  ,
         p_data     TYPE     igs_data_tab,
         p_charttype     TYPE     char20,
         p_legend     TYPE     char20,
         l_igs_chart TYPE  REF TO cl_igs_chart ,
         l_igs_chart_engine TYPE  REF TO cl_igs_chart_engine,
         i_igs_image_converter TYPE REF TO cl_igs_image_converter,
         mime TYPE  w3mimetabtype,
         html TYPE  w3htmltabtype,
         html_line TYPE  w3html,
         l_msg_text(72) TYPE  c,
         l_url TYPE  w3url,
         l_content_length TYPE  i,
         l_content_type TYPE  w3param-cont_type,
         l_content_subtype TYPE  w3param-cont_type.
    CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
         filename                      = 'e:\katoch.jpg'
        filetype                      = 'BIN'
    *      HAS_FIELD_SEPARATOR           = ' '
    *      HEADER_LENGTH                 = 0
    *      READ_BY_LINE                  = 'X'
    *      DAT_MODE                      = ' '
    *      CODEPAGE                      = ' '
    *      IGNORE_CERR                   = ABAP_TRUE
    *      REPLACEMENT                   = '#'
    *      CHECK_BOM                     = ' '
    IMPORTING
        filelength                    = l_content_length
    *      HEADER                        =
       TABLES
         data_tab                      = mime
    EXCEPTIONS
        file_open_error               = 1
        file_read_error               = 2
        no_batch                      = 3
        gui_refuse_filetransfer       = 4
        invalid_type                  = 5
        no_authority                  = 6
        unknown_error                 = 7
        bad_data_format               = 8
        header_not_allowed            = 9
        separator_not_allowed         = 10
        header_too_long               = 11
        unknown_dp_error              = 12
        access_denied                 = 13
        dp_out_of_memory              = 14
        disk_full                     = 15
        dp_timeout                    = 16
        OTHERS                        = 17
    IF sy-subrc <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CREATE OBJECT i_igs_image_converter .
    i_igs_image_converter->input = 'image/jpeg'.
    i_igs_image_converter->output = 'image/x-ms-bmp'.
    i_igs_image_converter->width = '100'.
    i_igs_image_converter->height = '100'.
    CALL METHOD i_igs_image_converter->set_image
       EXPORTING
         blob      = mime
         blob_size = l_content_length.
    CALL METHOD i_igs_image_converter->execute
       EXCEPTIONS
         communication_error = 1
         internal_error      = 2
         external_error      = 3
         OTHERS              = 4.
    IF sy-subrc = 0.
       CALL METHOD i_igs_image_converter->get_image
         IMPORTING
           blob      = blob
           blob_size = blob_size
           blob_type = blob_type.
       DATA dsn1(20) TYPE c VALUE 'E:\test.bmp'.
    DATA wa_mime1 TYPE w3mime.
    *DATA wa_mime1 TYPE w3mimetabtype.
       OPEN DATASET  dsn1   FOR OUTPUT IN BINARY MODE.
       LOOP AT blob INTO wa_mime1.
         TRANSFER wa_mime1 TO dsn1.
         CLEAR wa_mime1.
       ENDLOOP.
    MESSAGE ' successfull' TYPE 'I'.
       CLOSE DATASET dsn1.
    ELSE.
       DATA: num TYPE i, message TYPE string.
       CALL METHOD i_igs_image_converter->get_error
         IMPORTING
           number  = num
           MESSAGE = message.
    MESSAGE 'not successfull' TYPE 'I'.
    ENDIF.

    HI
    i already converted it in binary form but when i transferring it to binary mode it generate error.
    the code is like this.
    LOOP AT blob INTO wa_mime1.
         TRANSFER wa_mime1 TO dsn1.
         CLEAR wa_mime1.
       ENDLOOP.
       CLOSE DATASET dsn1.

  • How to skip for loop execution

    Hi all,
    How to skip execution of for loop , if one particular condition is satisfied within that loop .
    I know that we can use exit within for loop to come out of for loop, please let me know if there is any other approach .
    Thanks,
    P Prakash

    BluShadow wrote:
    11g (new feature) - it is called the CONTINUE statement.Blergh! it's horrible. May as well use a GOTO.... :{noformat}/{noformat}Hehe.. Yeah - it essentially creates another exit point in the loop, except that it falls into the top of the loop and not out of the bottom.
    So in that respect, the EXIT statement ain't much better. {noformat} ;-) {noformat}
    Personally I don't think it that bad - could be useful for very tight loops where you want to cut down machine code to the absolute minimum. But then why would one ever write such a loop in PL/SQL?
    Reserving judgement on this one for the time being. I very very seldom have used a continue or skip instruction in programming... As far as I recall - only in bash shell scripts.
    So yeah, I would like to see the code and justification for that code using the CONTINUE statement. There always could be The Real And Seldom Seen Bigfoot-like Exception that justifies using that statement... {noformat} :-) {noformat}

  • How to create for loop USING a while loop

    Hi, I would like make a for loop inside of a while loop because I want to control the i count of the loop, and overall, more control over the loop. From what I understand, labVIEW's for loop doesn't let me change where the i count starts. It always start at i=0, and what I want to do is be able to jump to specific loop iterations and then continue from there.
    Thank you.

    That is not the same as the earlier examples.
    If you want 10 counts and start at 0, then the stop terminal will stop after 10 times.  Just like you get when you wire 10 into the N terminal and don't have a conditional loop.
    If your start value is larger, let's say 9, then your loop will only run 1 time because i=0 on first iteration + 1+ 9 (start value).  0 + 1 +9 = 10.
    If your start value is larger than 10, then it will run 10 times again because on the intial iteration the result of your comparison is already greater than 10 and won't stop, and will never be equal on later iterations.
    So your example does not even give consistent results depending on the value you use as the start value.
    (Just to note, my earlier examples may not all be identical results as I didn't try to verify all the stop conditions nor the array that is output by the ramp function.  I could be off by one iteration here or there.  But they should be good enough to point out distinctive ways to accomplish what the OP asked for.)

  • I need java for come into my bank?

    I need java for open my bank account, what i do to get it?

    Java is not supported on the iPad. Does your bank have its own app in the app store or a non-java version of its website ?

  • How update java for mac os x 1.6.8

    hi
    idont know how update java 7
    my mac 1.6.8 
    when i update they tell me , icant update , you should my mac 1.7
    i dont know what i do 
    help me plaz 
    i waitting you

    I am running 10.6.8 and I have discovered the latest Java is causing serious problems with Firefox to the point I will get a grey screen.  After I reboot and look at the crash log, it is always firefox that is the issue but I am having different issues with Google.   Sadly to say, there are a number of other apps that either launch then fail or do nto work at all since the latest Java update.  Is there a way to go back?

  • How to write "for loop" for this block in as3?

    hello all, could you please help me to write a for loop for the following code?
    PS: bx1,bx,2bx3... are movie clips, xfir1,xsay1,xad1,xtip1,xdil1 are dynamic text boxes.
    var xmlLoader9:URLLoader = new URLLoader();
    xmlLoader9.addEventListener(Event.COMPLETE, showXML99);
    xmlLoader9.load(new URLRequest("spops.xml"));
    function showXML99(e:Event):void
    XML.ignoreWhitespace = true;
    var fir:XML = new XML(e.target.data);
    bx1.xfir1.text =  fir.sno[0].aa.text();
    bx1.xsay1.text =  fir.sno[0].bb.text();
    bx1.xad1.text  =  fir.sno[0].cc.text();
    bx1.xtip1.text =  fir.sno[0].dd.text();
    bx1.xdil1.text =  fir.sno[0].ee.text();
    bx2.xfir2.text =  fir.sno[1].aa.text();
    bx2.xsay2.text =  fir.sno[1].bb.text();
    bx2.xad2.text  =  fir.sno[1].cc.text();
    bx2.xtip2.text =  fir.sno[1].dd.text();
    bx2.xdil2.text =  fir.sno[1].ee.text();
    bx3.xfir3.text =  fir.sno[2].aa.text();
    bx3.xsay3.text =  fir.sno[2].b.text();
    bx3.xad3.text  =  fir.sno[2].cc.text();
    bx3.xtip3.text =  fir.sno[2].dd.text();
    bx3.xdil3.text =  fir.sno[2].ee.text();

    And for the second, try this:
    var stThings:Array = [st1, st2, st3];
    var bxThings:Array = [bx1, bx2, bx3]
    var globalURLRequest:URLRequest = new URLRequest ("tgs.aspx?st=1003")
    for each(var stWhat in stThings)
    stWhat.addEventListener(MouseEvent.CLICK, clickHandler);
    stWhat.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
    stWhat.addEventListener(MouseEvent.MOUSE_OUT , outHandler);
    function clickHandler(event:MouseEvent):void
    navigateToURL(globalURLRequest,"_blank")
    function overHandler(event:MouseEvent):void
    var index:int = stThings.indexOf(event.target);
    bxThings[index].visible = true;
    function outHandler(event:MouseEvent):void
    var index:int = stThings.indexOf(event.target);
    bxThings[index].visible = false;
    It's difficult to interpret your code--you may want to take some time to write more readable code.
    For example, what is an 'st1'? Is it a button? What does it do?
    Consider if it were a button made to load Story 1... a much more readable name would be btnStory1.
    Also, there really is no advantage to identifying events as eeeeevt, zeeeevt and changing those.
    Pick a convention and stick to it. I prefer 'event', others use 'e' or 'evt'.
    And try to use function names that mean something, "function a1003mo(zeeevt2:MouseEvent):void {" is much more easily read as "function outHandler(event:MouseEvent):void"
    I'd be interested to see what it is you're making, I believe there are some real opportunities to optimize it.
    HTH
    -Ted

  • Java "for loop" in KM

    Hi All,
    I have a Table(I$_Customer) where i have data like this:
    CN;CA; CAD; Row_type; Rank; File_number
    CN;CA;CAD;1; 0; 1
    A; 25; A; 2; 1; 1
    B; 60; B; 2; 2; 1
    C; 15; C; 2; 3; 2
    D; 23; D; 2; 4; 2
    E; 21; E; 2; 5; 2
    F; 21; F; 2; 6; 3
    G; 25; G; 2; 7; 3
    H; 25; H; 2; 8; 3
    I; 25; I; 2; 9; 3
    J; 26; J; 2; 10; 3
    This is my data i have to load rows to different files using 1 interface based on the file_number column
    so first 3 rows will need to load to file :customer_1
    next 3 rows need to load to file :customer_2
    and rest of the rows to file: Customer_3
    In the IKM i have a command Sqlunload which is executing on Sunopsis API Technology:
    import.java.sql.*;
    int var_counter;
    For(var_counter=1;var_counter<=5;var_counter++)
    Sqlunload with where clause file_number=var_counter
    I have not used java + Sunopsis API
    so if any body can help is very great
    Thanks
    Edited by: Gourav Atalkar(ELT) on Feb 28, 2013 3:46 AM

    Oh, I see.
    Can you tell me the name of your IKM ? It would be easier to help you.
    I don't know Java and Jython, so I can't really help you with this technology.
    But I've got an idea. You could use the "command on destination" / "command on source" tabs to generate your loop.
    0) You have created your I$ table with the 3 news columns. Right ?
    1)Then, you could create an extra step that will create and load N "I$_X" tables.
    in "command on source tab", you write an SQL statement like this :
    "select distinct FILE_NUMBER from I$"in "command on destination tab", you write an SQL Statement like this :
    create table I$_#FILE_NUMBER(you can duplicate the "create flow table" and just add the #FILE_NUMBER)
    With that, the IKM will execute the "create table" statement for each result of the "select distinct file_number" statement.
    So it will create 3 I$ tables : I$_1 ; I$_2 ; I$_3.
    2) Then, you will have to add a news step that will load these I$ table.
    in "command on source tab", you write an SQL statement like this :
    "select distinct FILE_NUMBER from I$"in "command on destination tab", you write an SQL Statement like this :
    insert into table I$_#FILE_NUMBER
    select .. from I$ where FILE_NUMBER = #FILE_NUMBER3) Then you will have to use the same technique to create many files

  • Java for loop

    I have to design and create a program that reads in a sequence of student grades and computes the average grade, the number of students who pass (a grade of at least 60) and the number who fail. The program prints the total number of student, average grade, number of students who pass and number of students who fail.
    I have written the pseudocode as follows, which i believe is flawed, hence the following code is not working either. Any help would be appreciated.
    Read the number of students
    Start loop
    Read a number for the first student
    Student total grades = Student total grades + student grade
    Calculate the total of all the students marks
    End loop
    Calculate average grade for the students
    If the student grade is greater than 60
    calculate how many students got grade 60 and above ??
    Else
    calculate how many students got grade 59 and below??
    Print to the screen total amount of students
    Print to the screen the average grade
    Print to the screen the amount of student that have passed
    print to the screen the amount of students that have failed
    import java.io.*;
    public class grades
    public static void main (String args [])throws IOException
         int averagegrade, grade, numberofstudents, totalgrades,storage,sumpassed,sumfailed;
         String information ;
         BufferedReader stgin = new BufferedReader ( new InputStreamReader ( System.in ) );
         sumpassed = 0;
         sumfailed  = 0;
         numberofstudents = 0;
         totalgrades = 0;
         grade = 0;
         averagegrade = 0;
         System.out.println ("Enter the number of students");
         information = stgin.readLine();
         numberofstudents = Integer.parseInt (information) ;
         for (  storage = 0 ;   storage < numberofstudents ; storage ++ )
         System.out.println ("Enter grade of a student");
         information = stgin.readLine();
         grade = Integer.parseInt( information );
            totalgrades = totalgrades + grade;
           averagegrade = totalgrades / numberofstudents;
             if (grade >= 60 )
             sumpassed = sumpassed + numberofstudents  ;
         else
         sumfailed = sumfailed + numberofstudents ;
         System.out.println ( " Total amount of students entered " + numberofstudents );
         System.out.println ( " The average student grade is " + averagegrade);
         System.out.println ( " Total amount of students that passed is " + sumpassed);
         System.out.println ( " Total amount of students that failed is " + sumfailed );
    }

    I have a very similiar project I need to do. I need to find averages of grades. They need to be between 0 - 100 or a message is given. Once grades are all entered they need to be averaged and that needs to be displayed. I am new new new to this and an so lost! Here is what I have so far, if ANYONE can help it would be great. I have to have this finished by this evening. UGH!
    import javax.swing.*;
    public class Grades2
         public static void main(String[] args)
              int count = 0; // Initialize these to zero.
              int total = 0; // Initialize these to zero
              int avg = 0; // Initialize these to zero.
              int input; // Don't need to initialize, but it won't hurt
    // Display a message requesting a grade between 0 and 100
         System.out.println("Enter numerical grades");
              input = value; // Store the input to variable input
              while(input != 999) {     // If they entered 999, the while loop will not run.
    if ((input >= 0) && (input <= 100)) // Check if value is in the range of 0 to 100
    count ++; // Increment the number of values input
    total += input; // Add the input to the running total
    else
    {           // the value was not between 0 and 100, the while loop will check to see if it is 999
         JOptionPane.showMessageDialog(null, "Enter a valid grade",
                   "Grades Program", JOptionPane.INFORMATION_MESSAGE);
    // Do not increment count
    // Do not increment the total.
    input = JOptionPane.showInputDialog("Enter a Final Grade: ");
    // Input = new value;
                                       } // This loop will continue to run until the user enters 999 as the input
                   if (count == 0) {           // I'm doing this check because you don't want to do a divide by zero
         JOptionPane.showMessageDialog(null, "No grade has been issued",
                   "Grades Program", JOptionPane.INFORMATION_MESSAGE); ;
                   else {
         System.out.println("The average is: " + total / count);
         }

  • Nested For Loop Trouble?

    Ok I need to have a nested for loop that asks a user to enter in a int number from 1-50. Whatever the number is, lets say 4 I need the program to count up asterisk and count down asterisks, like this.
    This is my code:
    import java.io.*;
    public class Stars {
         static int n;
         static private InputStreamReader in = new InputStreamReader(System.in);
         static private BufferedReader br = new BufferedReader(in);
         public static void main(String[] Args)throws IOException
              System.out.println("Please enter in a number to see display: ");
              String num = br.readLine();
              n=Integer.parseInt(num);
              for(int i=1;i<=n;i++)
                   for(int j=1;j<=i;j++)
                        System.out.print("*");
                   for(int j=1;j<=i;j--)
                        System.out.print("*");
                   System.out.println();
    Can someone tell me what I am doing wrong so I can figure out my mistake(s).

    Ok, well I know that the loop relies on the number entered in by the user. So if i pick 3 the three enter in the loop and counts up in a for loop and for every number it counts up to the three it does a print("*"); Now what I am getting confused about is where the other for loop comes into play. I know that I need to start from the number I have which is 3, so I need to have one less than that and then count down. The thing is that i'm not sure where or how the second for loop gets implemented into the code. Does it get nested with the first loop like this:
    for(int i=1;i<=n;i++)
                   for(int j=1;j<=i;j++)
                            for(int j=n-1;j>=i;j--)
                        System.out.print("*");
                   System.out.println();
              }Or is the second for loop on its own like this:
    for(int i=1;i<=n;i++)
                   for(int j=1;j<=i;j++)
                        System.out.print("*");
                   for(int j=n-1;j>=i;j--)
                        System.out.print("*");
                   System.out.println();
              }If someone can help me understand, for this is my first time with nested for loops.

  • Reset Text Items in For Loop

    Hi everybody,
    OS: Windows XP SP2
    Forms: 10.1.2.0.2
    Browser: FireFox 2.0.0.5
    I have in my form (100 text items) and the following code:
    DECLARE
    i NUMBER := 0;
    BEGIN
    FOR i IN 1 .. 100 LOOP
    SET_ITEM_PROPERTY( 'txt_segment_' || i , VISIBLE , PROPERTY_FALSE );
    SET_ITEM_PROPERTY( 'txt_segment_' || i , ENABLED , PROPERTY_FALSE );
    END LOOP;
    END;
    I want to reset all text items in my for loop i.e.
    txt_segment_1 = '';
    txt_segment_2 = '';
    txt_segment_100 = '';
    But I want to do it in the for loop, how ??
    Please help, and best regards ('',)

    Kevin .. you are GENIUS ;)
    It worked with NAVIGABLE set property.
    I have another question since you're around :)~
    I'm trying to concatenate all text items in a for loop into a varable x with the following code:
    FOR i IN 1 .. 100 LOOP
    COPY( x || 'txt_segment_' || i , x );
    END LOOP;
    but I end up with the following error:
    FRM-40738: Argument 2 to builtin COPY cannot be null.
    Its equivalent to the following code:
    x := x || txt_segment_1;
    x := x || txt_segment_2;
    x := x || txt_segment_100;
    OR equivalent to:
    x := txt_segment_1 || txt_segment_2 || .. || txt_segment_100;

Maybe you are looking for