Help with loops inside a method

I am having a bunch of problems creating a loop inside my 'mean' method. What i want do is set up a loop to give me the average of the numbers of the input that i entered. Can anyone assist me in creating this loop?
My code:
import java.io.*;
import java.text.*;
import java.util.StringTokenizer;
public class Labtest6{
public static void main (String args []) throws IOException {
int MAX = 100;
int MIN = 0;
int [] list = new int [MAX];
int count = 0; // ammount of items//
double guess;
double x;
double avg;
double var;
double stdDev;
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
NumberFormat nf = NumberFormat.getNumberInstance ();
nf.setMaximumFractionDigits (2);
nf.setMinimumFractionDigits (2);
count = read_list (list);
avg = mean (list, count);
System.out.println (count);
System.out.println (avg);
public static int read_list (int [] list)throws IOException {
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
int count = 0;
String item = stdin.readLine ();
while (item != null)
list [count] = Integer.parseInt (item);
++ count;
item = stdin.readLine ();
return (count);
public static double mean (int [] list, double count) {
thanks

That's not our job. It is your homework. Once you have made an attempt at it and can't get it to work, paste your code and ask a specific question. You won't get any help if all you do is whine about how you can't do it.
P.S. When pasting code, highlight it and click the code button to retain formatting.
Message was edited by:
flounder

Similar Messages

  • Help with looping and counting

    i am in a CS 1 class and need help with this loop
    /*Write a program that will allow the user to enter a character
              until the capital letter Z is entered
         The program should count the number of letters entered
              and print the total after the loop is completed*/
    here is what i have it doesn't end nor does it count and i don't know hwo to make it count also i suck at do..while loops hehe
    char b,Z=0;
              Scanner a = new Scanner(System.in);
         do
                   System.out.print("Enter a letter: "+"\n");
                   b=a.next().charAt(0);
              while (b !=Z);
    i know that its not even close to being right just help me out here
    Edited by: purplesmurf on Nov 14, 2008 7:25 PM

    The following program will count the number of chacters entered until Z is enetered.
    import java.io.*;
    class count
         public static void main(String[] args)throws IOException
              char ch;
              int cnt=0;
              DataInputStream br=new DataInputStream(System.in);
              do
              System.out.print("Enter a character:");
              ch=(char)br.read();
              if(ch!='Z')
                   cnt++;
              else
                   break;
              }while((ch=(char)br.read())!='Z');
              System.out.println("The Number of entered characters are:"+cnt);
    }

  • I need Help with loop

    Hello everyone this is my first time posting here, i have always find java easy(up to this point), this is my first class in programming java i am just needing help with the "for loops" i cant seem to get the program generate 10 random math questions. if you guys can please help i will appreciate it, i have been working on it for a couple of hours. I am not finished with it yet but thats the only thing i need help with.
    import javax.swing.JOptionPane;
    public class Lab5
    public static void main(String[] args)
    int num1 = (int) (Math.random() * 100 + 1);
    int num2 = (int) (Math.random() * 100 + 1);
    int sum = num1 + num2;
    int product = num1 * num2;
    int quotient = num1 / num2;
    int difference = num1 - num2;
    for (int i = 0; i > 11; i++);
    int number = (int)(Math.random()*4);
    if (number == 0 )
    String s1 = JOptionPane.showInputDialog(null, num1 + " + " + num2 + "=" );
    if(number == 1)
    String s3 = JOptionPane.showInputDialog(null, num1 + " - " + num2 + "=" );
    if(number == 2)
    String s3 = JOptionPane.showInputDialog(null, num1 + " x " + num2 + "=" );
    if(number == 3)
    String s4 = JOptionPane.showInputDialog(null, num1 + " ÷ " + num2 + "=" );

    for (int i = 0; i > 11; i++);Two problems with this line:
    1) The second part of a For loop is the constraint. You have said that for the loop to be entered, i must be greater than 11. Well since you've also told i to begin at 0, this will never happen. Thus, the loop will never enter. You may have meant less than?
    2) You put a semicolon in the line. Semicolons are used to end statements. The For loop, when used as a block with curly braces, is not a single statement and does not require a semicolon. Here's the two structures of a basic For loop:
    for(int i = 0; i <= 100; i++) {
        //this is a block. you can put multiple statements in here and they are all part of the loop
        int a = 1;
        int b = i;
    //if your loop only needs to use a single statement, no braces are required
    for(int i = 0; i <= 100; i++)
        int a = i;

  • Help with writing a static method in my test case class inside blue j

    I have this method that I have to test. below is the method I need to test and what I have to create inside my test case file to test it Im having big time problems getting going. Any help is appreciated.
    public String introduceSurprise ( String first, String last ) {
    int d1 = dieOne.getFace();
    Die.roll();
    if (d1 %4 == 2){
    return Emcee.introduce(first);
    else {
    return this.introduceSpy (first,last);
    So how do write tests to verify that every fourth call really does give a randomized answer? Write a static method showTests which
    creates an EmCee,
    calls introduceSurprise three times (doing nothing with the result (!)),
    and then calls it a fourth time, printing the result to the console window.
    Write this code inside your test class TestEmCee, not inside EmCee!

    hammer wrote:
    So how do write tests to verify that every fourth call really does give a randomized answer? Write a static method showTests which
    creates an EmCee,
    calls introduceSurprise three times (doing nothing with the result (!)),
    and then calls it a fourth time, printing the result to the console window.
    Write this code inside your test class TestEmCee, not inside EmCee!Those instructions couldn't be anymore straightforward. Make a class called TestEmCee. Have it create an EmCee object. Call introduceSurprise on that object 3 times. Then print the results of calling it a 4th time.

  • Need help with loop cursor

    Hi,
    I'm doing a data conversion and am fairly new to PL/SQL.
    I have a cursor and in the loop i have a select statement
    which returns ORA-01403(no data found). I need to skip this
    row in the cursor and continue with the next.
    BEGIN
    OPEN cur_fill_split;
    LOOP
    FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
    S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
    EXIT WHEN cur_fill_split%NOTFOUND;
    select order_number INTO N_ORDER_NUMBER from order_header
    where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
    SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    ********(errors on the above select)********
    END LOOP;
    CLOSE cur_fill_split;
    END;
    Thanks,
    Brian

    Hi,
    I think there r 2 methods, one is by giving begin - end inside the loop as shown below 1st ex:
    & the 2nd method is by selecting the record count & then based on that value executing further commands.
    I think 2nd method is more safer than the 1st method.
    Method 1:
    1)
    -- ---------------Procedure Begin------------------
    BEGIN
    OPEN cur_fill_split;
    LOOP
    FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
    S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
    EXIT WHEN cur_fill_split%NOTFOUND;
    select order_number INTO N_ORDER_NUMBER from order_header
    where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
    BEGIN
    SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    END;
    END LOOP;
    CLOSE cur_fill_split;
    END;
    -- ---------------Procedure End------------------
    Method 2)
    By selecting the record count & based on that records, deciding the program control.
    -- ---------------Procedure Begin------------------
    declare
    rec_cnt number := 0;
    BEGIN
    OPEN cur_fill_split;
    LOOP
    FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
    S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
    EXIT WHEN cur_fill_split%NOTFOUND;
    select order_number INTO N_ORDER_NUMBER from order_header
    where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
    /* Here we are using cnt variable & checking for
    the record count, if count = 0, then it will skip */
    select count(*) into rec_cnt from ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    if rec_cnt > 0 then
    SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
    WHERE ORDER_NUMBER = N_ORDER_NUMBER
    AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
    end if;
    END LOOP;
    CLOSE cur_fill_split;
    END;
    -- ---------------Procedure End------------------
    Try it out & mail me
    Good luck

  • Help with loop in code

    I have the following servlet which connects to a database and should brgin back the name of all films that an actor has stared in below is part of the servlet my problem is each time i run the servlet it just prints out "sorry there has been an error" a number of times. Can any body help me get this working?
    public static int MAX_COUNT = 100;
    int curr_item = 0;
    private static CatalogItem addedItem[] = new CatalogItem[MAX_COUNT];
    private static CatalogItem items[] = new CatalogItem[MAX_COUNT];
    CatalogItem item;
    CatalogItem details;
    public static CatalogItem getItem(int recordingid) {
               CatalogItem item;
              for(int i=0; i<items.length; i++) {
                item = items;
              addedItem[i] = items[i];
    if (recordingid==item.getrecordingid()) {
    return(item);
    return(null);
    // Database connection
         int recordingidDB;
         String directorDB;
         String titleDB;
         String categoryDB;
         String imageDB;
         int durationDB;
         String ratingDB;
         String yearDB;
         float priceDB;
         int StockDB;
         Connection conn = null;
         try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         } catch(Exception e) {
         System.out.println(e);
         try{
         conn = DriverManager.getConnection
    ("jdbc:myurl");
         // System.out.println("Connection to database successful.");
    catch(SQLException se) {
         System.out.println(se);
         try{
                   String category = request.getParameter("category");
         String selectSQL = "select recording_id, director, title, category, image_name, duration, rating, year_released, price, stock_count "+
         "from video_recordings " +
                        "where recording_id IN "+
                        "(select recording_id "+
                        "from video_actors "+
                        "where name ='"+request.getParameter("category")+"')";
    System.out.println(selectSQL);     
         Statement stmt = conn.createStatement();
         ResultSet rs1 = stmt.executeQuery(selectSQL);
         while(rs1.next() && curr_item < MAX_COUNT){
              recordingidDB = rs1.getInt("recording_id");
              directorDB = rs1.getString("director");
              titleDB = rs1.getString("title");
              categoryDB = rs1.getString("category");
              imageDB = rs1.getString("image_name");
              durationDB = rs1.getInt("duration");
              ratingDB = rs1.getString("rating");
              yearDB = rs1.getString("year_released");
              priceDB = rs1.getFloat("price");
              StockDB = rs1.getInt("stock_count");
         item =
              new CatalogItem
              (recordingidDB, directorDB, titleDB, categoryDB, imageDB, durationDB, ratingDB, yearDB, priceDB, StockDB);
              addedItem[curr_item] = item;
    items[curr_item++] = item;
    int ITEM_COUNT = curr_item;
         String pagetitle = "Catalog Items";
    out.println(
    "<BODY BGCOLOR=\"#a00e0e\">\n" +
              "<center></center>\n" +
    "<H1 ALIGN=\"CENTER\">" + pagetitle + "</H1>\n");
         // loop to go over each item in the array of catalogItem
         for(int i=0; i<addedItem.length; i++) {
         details = items[i];
         if (details == null) {
    out.println("SORRY THERE HAS BEEN AN ERROR ");
         } else {  
              for(int j=0; j<MAX_COUNT; j++) {
    out.println(
    addedItem[j].gettitle() + "\n" +
    addedItem[j].getprice() + "\n" +
    addedItem[j].getstock() + "\n" );
         out.println("</BODY></HTML>");
         stmt.close();
         conn.close();
         } catch(SQLException se) {
         System.out.println(se);

    ok..
    1. To print the size of the resultset there is no direct way from wat i know so far. You need to work around it. This wat i normally do for testing:
    String selectSQL = "select count(video_recordings.recording_id) " +
                                "from video_recordings " +
                        "where recording_id IN "+
                                                 "(select recording_id "+
                                                "from video_actors "+
                                                 "where name ='"+request.getParameter("category")+"')";
    Statement stmt = con.createStatement() ;
    ResultSet rs = stmt.executeQuery(selectSQL) ;
    rs.next() ;
    BigDecimal rowCount = rs.getBigDecimal(1) ;
    System.out.println("Result size = " + rowCount.toString());The rowCount variable now contains the size of your query result.
    2. To print the stacktrace, just add in se.printStackTrace into your catch blocks.
    Additional: Can u also print something inside youe while loop to confirm that your code did enter the while loop and perform the assignment?
    Maybe u can also print the addedItem[curr_item] value after you addedItem[curr_item] = item to confirm that the item was successfully assigned to addedItem[curr_item]..

  • Help with Loop Function

    I am trying to automate converting Pages documents to Word. Maybe later to reopen them in Pages but with the options set to create flat files.
    I select the files I want and they open ok. The export goes ok and I click the file close button,
    Maybe this close does not work as I get twice as many files open after each loop.
    How do I stop the loop function bringing all the files in again each time.?
    Get Selected Items
    Open Finder Items
    Watch Me Do:
    Click "Pages" in the Dock
    Click the "File" menu
    Export
    Click the "Next..." button
    Click the "<fill the title>" button
    Loop (use the current results as input)
    Your help would be welcome!
    Message was edited by: putnik

    Thanks again,
    The "Dispense Items Incrementally" seems to work well enough. However, now the workflow stops at the end of the second loop. The file is closed but the "Watch Me" function seems to want something else to happen (it continues active). The only first file is still listed in the loop function.
    Get Selected Items
    Dispense Items Incrementally
    Open Finder Items
    Watch Me Do:
    Click "Pages" in the Dock
    Click the "File" menu
    "Export"
    Type '
    Type '
    <Cmd W>
    Loop (up to 10 times, use the current results as input)
    Note that I am learning to avoid mouse gestures where possible as things move about to much...
    Any idea what I need to do?

  • Help withe loop on tables

    Hallow in my table itab I have employee (sobid employee number and names ex. 80 emp) in my loop(b_itab) I get all he employee that doing the course (their sobid just 3 emp) how can I use b_itab to write to other table (d_itab) to write all the employee that don’t doing the course .I need a  general solution.
    <b>Ex.i have a table with 80 emp and I doing a loop on this table and find 3 employee that doing course how can I do  comparison in the 2 table that if the employee not in b_itab(emp doing course) write them in d_itab(oteer table).</b>    .if u need more details  please let me now.
    regards

    Loop at itab.
    Specify the condition here if they are doing the course
    if (Condition here)
    append itab to b_itab.
    else
    append itb to d_tab.
    endif.
    endloop.
    The other option will be:
    loop at itab.
    read table b_itab with key course = itab-course.
    if sy-subrc NE 0.
    append itab to d_itab.
    endif.
    endloop.
    Can you try these options? If not, please give the structure of the internal table to know exactly you want to do.
    Best Regards,
    Vibha
    *Please mark all the helpful answers

  • Need help with a reverse number method

    hey all..
    i have this program which should return the integer reversed ..
    i have done this program using methods.. but the problem is if the
    number endes with 0 when it reversed the output doesn't contain the number 0
    for example:
    input
    123450
    output
    54321
    where before the 5 there should be 0
        This program that reads an integer and then calls a method
          that receives an integer and returns the integer with its digits reversed.
          Main prints the resulting integer.
       import java.util.Scanner; // program uses class Scanner
        class Sh9q4
           // main method begins execution of Java application
           public static void main( String args[] )
          // create Scanner to obtain input from command window
             Scanner input = new Scanner( System.in );
             int number; // The number entered by the user
             System.out.println("Enter an integer"); // prompt for input
             number = input.nextInt(); // read the the integer
             reverse (number); // print the method reverse
          } // end method main
           public static void reverse ( int num )
             int lastDigit; // the last digit returned when reversed
             int reverse = 0;
             do
                lastDigit = num % 10;
                reverse = (reverse * 10) + lastDigit;
                num = num / 10;
             while (num > 0);
             System.out.println("The integer with its digits reversed " + reverse); // print the integer reversed
          }// end method reverse
       } // end class Sh9q4thanks for your help :)

    If you need the leading zero to display, then you will have to do as Keith recommended and convert the input number to a String, then reverse that String and print it as a String.
    A number is a number is a numerical value, and there is no difference between the value of 054321 and 54321 except when written as a literal, when the first is an octal, and the second a decimal, value.
    If you are still confused, plug in these few lines of code and run them:String str = "012345";
    int x = Integer.parseInt (str);
    System.out.println(str);
    System.out.println(x);db

  • Help with Comboboxes inside a repeater

    Hi, I have a problem that I really need some help, if anyone knows how to do it.
    I have to make in flex a dynamic form that has X questions and each question can be answered 3 times by sellecting Y options in a combobox. As you can Imagine the number of questions and answers can change.
    Something like this:
    QUESTION                          FIRST ANSWER   2nd ANSWER      3rd ANSWER
    1- Which option do you like?  Combobox: A      Combobox: C        CB: A
    2- Second Question?             Combobox: B      Combobox: C        CB: D
    3- Third Question?                 Combobox: A      Combobox: Blank  CB: B
    (CB: means Combobox - I just made it shorter so it could fit the window)
    I managed to correctly using a repeater show all the questions and each combobox has all the right options inside. All I want now is to get the data from those comboboxes.
    This is a Simplified code (I removed all the non-essencial stuff) so you can get an idea:
    <mx:Repeater id="rp">
    <mx:VBox label="{rp.currentItem.nome}"
    width="100%">
    <mx:Repeater id="qt"
    dataProvider="{rp.currentItem.tbdavaliacao_pergunta}">
    <mx:HBox width="100%"
    verticalAlign="middle"
    horizontalAlign="center">
    <!-- This is the question text -->
    <mx:Text text="{String(qt.currentItem.nome)}"
    textAlign="center"/>
    <!-- Next, are the 3 comboboxes that are repeated X times -->
                                            <mx:ComboBox dataProvider="{grau}"
                                                           id="auto"
                                                           textAlign="center">
                                             </mx:ComboBox>
                                            <mx:ComboBox dataProvider="{grau}"
                                                           id="superior"
                                                           textAlign="center">
                                            </mx:ComboBox>
                                            <mx:ComboBox dataProvider="{grau}"
                                                           id="resultado"
                                                           textAlign="center">
                                            </mx:ComboBox>
    </mx:HBox>
    </mx:Repeater>
    </mx:VBox>
    </mx:Repeater>
    Anyone has an idea of how can I get all the answers from all my dynamic comboboxes?
    The perfect AND ideal solution would be having X Dynamic objects with the question id + the combobox id storing the answer sellected.
    So I would know that the question 32 has the answers A, B and A for an example.
    qt.currentitem.id + combobox.id = selectedLabel
    (question ID) + (combobox id) = (selectedLabel)
    32auto = 'A'
    32superior = 'B'
    32resultado = 'A'
    Or just one arraycollection with all the answers...
    At this point, I would accept any answer or idea or sollution...
    Thanks a lot!!

    I've looked at the HR schema to provide an example
    From the EMPLOYEES table I would like to return the EMPLOYEE_IDs of the employees with the highest SALARY per JOB_ID. When considering the employees that have the same JOB_ID, if any of the employees have a MANAGER_ID of x then no employee is returned for that group of employees with the same JOB_ID. x will be passed in as a parameter to my procedure.
    Example
    MANAGER_ID of 99 passed in
    All of the EMPLOYEE_IDs with the max SALARY per JOB_ID returned - no one has a manager with MANAGER_ID of 99
    MANAGER_ID of 101 passed in
    101 returned - Neena has the max salary of all the AD_VPs and neither of the AD_VPs has a MANAGER_ID of 101 (ok I know this isn't true about the salary!)
    102 returned - Alexander has the max salary of all IT_PROGs and none of them has MANAGER_ID of 101
    (108 not returned as Nancy has MANAGER_ID of 101)
    109 returned - Daniel has the max salary of all the FI_ACCOUNTs and none of them has MANAGER_ID of 101
    etc... for all JOB_IDs
    MANAGER_ID of 102 passed in
    101 returned - Neena has the max salary of all the AD_VPs and neither of the AD_VPs has a MANAGER_ID of 102 (ok I know this isn't true about the salary!)
    (no IT_PROGs returned as Alexander has MANAGER_ID of 102)
    108 returned - Nancy has max SALARY and not a MANAGER_ID of 102
    109 returned - Daniel has the max salary of all the FI_ACCOUNTs and none of them has MANAGER_ID of 102
    etc... for all JOB_IDs
    MANAGER_ID of 103 passed in
    101 returned - Neena has the max salary of all the AD_VPs and neither of the AD_VPs has a MANAGER_ID of 103 (ok I know this isn't true about the salary!)
    (no IT_PROGs returned as several have MANAGER_ID of 103)
    108 returned - Nancy has max SALARY and not a MANAGER_ID of 103
    109 returned - Daniel has the max salary of all the FI_ACCOUNTs and none of them has MANAGER_ID of 103
    etc... for all JOB_IDs
    Hope this helps to explain things, and thanks to anyone that can help
    Rob

  • Help with Deque, insertRight() removeLeft() Methods in particular

    Hello,
    I am attempting to implement a deque, I have working insert left and remove right methods as a normal queue works. --->
    However I am having trouble implementing my insert right and remove left methods... keep hitting an array out of bounds problem, guess my wrap arounds aren't working properly. I've tried drawing this out, and I still can't seem to get this to work, can someone please help?
          * Javadoc Here
         public void insertRight(long j) {
              if (front == - 1)
                   front = maxSize-1;
              queArray[++front] = j;
              nItems++; // one more item
          * Javadoc Here
         public long removeLeft() {
              long temp = queArray[rear--];
              if (rear == -1)
                   rear = maxSize;
              nItems--; // one less item
              return temp;
         }

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
         at Deque.removeLeft(Deque.java:71)
         at DequeApp.main(Deque.java:134)
    My javadocs are written because im still in the process of writing the damn thing, give me a break please?
    * This class is to demonstrate.....
    * @version 1.0
    public class Deque {
         private int maxSize;
         private long[] queArray;
         private int front;
         private int rear;
         private int nItems;
          * Java Doc
         public Deque(int s) // constructor
              maxSize = s;
              queArray = new long[maxSize];
              front = 0;
              rear = -1;
              nItems = 0;
          * Javadoc Here
         public void insertLeft(long j) {
              if (rear == maxSize - 1) // deal with wraparound
                   rear = -1;
              queArray[++rear] = j; // increment rear and insert
              nItems++; // one more item
          * Javadoc Here
         public long removeRight() {
              long temp = queArray[front++]; // get value and incr front
              if (front == maxSize) // deal with wraparound
                   front = 0;
              nItems--; // one less item
              return temp;
               * Javadoc Here
              public void insertRight(long j) {
                   if (front == - 1)
                        front = maxSize-1;
                   queArray[++front] = j;
                   nItems++; // one more item
               * Javadoc Here
              public long removeLeft() {
                   long temp = queArray[rear--];
                   if (rear == -1)
                        rear = maxSize;
                   nItems--; // one less item
                   return temp;
          * Javadoc Here
         public boolean isEmpty() {
              return (nItems == 0);
          * Javadoc Here
         public boolean isFull() {
              return (nItems == maxSize);
    }// end Deque Class
    class DequeApp {
         public static void main(String[] args) {
              Deque q1 = new Deque(5); // queue holds 5 items
              q1.insertLeft(10); // insert 4 items
              q1.insertLeft(20);
              q1.insertLeft(30);
              q1.insertLeft(40);
              q1.removeRight(); // remove 3 items
              q1.removeRight(); // (10, 20, 30)
              q1.removeRight();
              q1.insertLeft(50); // insert 4 more items
              q1.insertLeft(60); // (wraps around)
              q1.insertLeft(70);
              q1.insertLeft(80);
              while (!q1.isEmpty()) // remove and display
              { // all items
                   long n = q1.removeRight(); // (40, 50, 60, 70, 80)
                   System.out.print(n);
                   System.out.print(" ");
              System.out.println("----->");
              Deque q2 = new Deque(5); // queue holds 5 items
              q2.insertRight(10); // insert 4 items
              q2.insertRight(20);
              q2.insertRight(30);
              q2.insertRight(40);
              q2.removeLeft(); // remove 3 items
              q2.removeLeft(); // (10, 20, 30)
              q2.removeLeft();
              q2.insertRight(50); // insert 4 more items
              q2.insertRight(60); // (wraps around)
              q2.insertRight(70);
              q2.insertRight(80);
              while (!q2.isEmpty()) // remove and display
              { // all items
                   long n = q2.removeLeft(); // (40, 50, 60, 70, 80)
                   System.out.print(n);
                   System.out.print(" ");
              System.out.println("<-----");
         } // end main()
    } // end class DequeApp
    // //////////////////////////////////////////////////////////////

  • Help with looped equation

    I am really struggling here with this (what seems) fairly simple labview problem.  I have a set of equations that rely on the answer of the previous other formula and so forth.  I can do this easily enough in excel.  I tried to recreate this function in labview and have been really struggling to get it to work.  I have tried using while loops and for loops, which I think is what I need to do here, but I haven't had much success.  Anyways, I attached the spreadsheet with the two formulas, a .png showing the relationship of the formulas in the spreadsheet, and my .VI.  Thanks for your help in advance.
    Solved!
    Go to Solution.
    Attachments:
    Formula.xlsx ‏42 KB
    Formula.png ‏38 KB
    Untitled 1.vi ‏8 KB

    You need both a loop and a shift register.
    Lynn
    Attachments:
    Looped equations.2.vi ‏10 KB

  • Beginner needs help with subform inside of subform

    I need to add a few different subforms depending upon the answers given in the form.  The first level is phase. Then they answer the question does this phase have tasks?  If yes then I want the tasks subform to appear.  If no then I want then I want the working org subform to appear.  After they answer then they have the option of adding another phase and starting the process again.  I have the phase adding again, but cannot figure out to have addtional subforms in between the phases.  Any help or examples would be greatly appreciated.
    Thanks!

    The answer to this depends on how the content of the  tasks and working org sections are organized.  Since each phase entry is set up as a table that's in a row of a parent table, the only way to insert a section under the phase would be to add a row.  You can add a row for tasks and a row for working org after the phase row, so that every time you insert a phase you'll get both.  Set them both to hidden, and unhide the appropriate row based on the answer to the "tasks" question.  The only issue is that if your task and working org info is complex it'll be tricky to format all of the info as a table row.  This can be done by making your row one cell wide (full width of the row) and setting that cell content to a subform, then adding all of your info into the subform.  However if there's a lot of data then the row constraint may be an problem.
    The other method would be to convert the phase section to a subform, then have three child subforms inside: phase, tasks and working org.  The idea is the same as what you're doing now, but you're using subforms rather than table rows.  You can add instances of subforms the same way that you add instances of table rows.
    I wired up your example using rows; see the attached form.

  • Help with Loops!! All loops are RED and unclickable after Leopard upgrade.

    I may need to just remove soundtrack pro from my computer and start from scratch again. When I upgraded to Leopard I failed to select preserve user settings when I did an archive and install. So therefore I had to find and drag files to the new library. This is on my Power Mac G5.
    I have a Macbook Pro laptop and I used that as a guide of how I have that set up. On my G5, I have all my loops in the same folders they are in on my laptop. When I open STP, and pull up my loop files, they are all listed in red. When I try to click on them, nothing happens.
    I have them set up as MAC>Library>Audio>Apple Loops>Apple Loops for Soundtrack Pro, Apple Loops for GarageBand, PowerFX Loops
    I am not sure if I am dealing with a bunch of corrupt files and need to start with a new slate or what.
    I also noticed that most if not all the audio loops end in .CAF instead of .AIFF in the folders. However when STP is open, the files ARE listed as .aiff files but they are red and non clickable.
    Any suggestions appreciated!
    Thanks!
    Message was edited by: DVX100Shooter
    Message was edited by: DVX100Shooter
    Message was edited by: DVX100Shooter

    Yea once I rearranged the loops and then opened STP and then Indexed those loops, I got everything back to normal except my Trumpet files. I cannot locate them anywhere. There are only 4 loops but I searched my HD and still can't locate where they are but I got everything else back to working.

  • Need help with loops! Where can I find them?

    I have garageband '09 and when I go through my loops, over half of them are missing. That is to say they are labeled and there is a list of them, but only half work, The rest of them are see-through text and wont play music. It has said I could get them back with a software update but it always comes back that everything is up to date. im wondering if they might be in a folder and garageband doesnt know of that folder as where to look or what. Any Ideas please??

    Bachman22 wrote:
    only half work, The rest of them are see-through text and wont play music. It has said I could get them back with a software update
    http://www.bulletsandbones.com/GB/GBFAQ.html#cantdownloadloops
    (Let the page FULLY load. The link to your answer is at the top of your screen)

Maybe you are looking for