Refining "if" loop some help is needed

Hi All,
I have the following if loop that works fine but only in one way.
int dist = 15;
int fromCompX = 0,fromCompY=0,toCompX=0,toCompY = 0;
if( (dist > Math.abs(toCompX-fromCompX)) || (dist > Math.abs(toCompY-fromCompY)) )
     toComp1.setLocation(toCompX,fromCompY);
     repaint();
}This loop makes the components in the panel come in a same line (HORIZONTALLY). e.g
     @   The above if loop makes the components like this
@   @   @I have no problem with this. But when I have a component in a vertical direction then problem starts. e.g
@The above components look like this after calling the if loop
@@What I need is
@See that the above component has just moved only to the right.
Any help would be great.
Thanks
Uma

Why not create another if loop? I am not sure this is going to work but try with this kind of logic.
if( (dist > Math.abs(toCompX-fromCompX)) || (dist > Math.abs(toCompY-fromCompY)) )
     if((dist > Math.abs(toCompY-fromCompX)) )
          toComp1.setLocation(toCompY,fromCompX);
          repaint();
     else
          toComp1.setLocation(toCompX,fromCompY);
          repaint();
}

Similar Messages

  • Can i plz get some help, i need to create a vi that gives equation of straight line and graphs

     a vi that inputs two set of coordinates and computes the equation of the straight line joining these two sets of coordinates and graphs this line, and then i must compute the equation of a line perpendicular to this line and passes through (x3,y3) and graph this line.

    You should try to learn Labview basics before trying to tackle a Labview program.  I'll give you a head start because you are probably under some time constraint.  Try to code this and then ask for help when you need it.
    To start you off, use a For Loop.  Your graph will be finite, so wire in a reasonable number into the N terminal of the loop.  Use the i terminal as your X input and calculate Y for each X.  The output of the loop will be an array of Y values.  You can graph those values. 
    Learn how to post your vi here.  There are several ways.  The best is to use Laabview 2009 and create a code snipet (look under the Edit menu).  Then add the snipet to your post by clicking the Upload or Insert Image icon above (the icon looks like a tree).  You can add the vi directley by clicking on Add Attachments below the Tags box.  Be sure to state which version of Labview you are using.
    - tbob
    Inventor of the WORM Global

  • Some help really  needed

    Hello,
    yesterday i had some problems with the usage of eclipse during my session with card. So i had to end the program through the task manager, because it seemed that it will never awake and continue the performance.
    Now during the work with my JCOP card through the JCOP shell, i have problems when i am trying to delete it . I mean card doesn't allow me to separately delete an Applet and my package then. Day before it worked fine. In the simulator it still works fine.
    It always return 6985 (Conditions not satisfied statement). Despite this fact, my Lodare.java module works fine. Call to the CardManager deleteObject() methos returns no errors. So it can delete only package by deleting related applets at once.
    Could you help, what could be solution or the basis for such problem occurrence?
    Best regards,
    Eve

    here is my APDU trace:
    -  /terminal "winscard:4|SCM Microsystems Inc. SCR3310 USB Smart Card Reader 0"
    --Opening terminal
    /card -a a000000003000000 -c com.ibm.jc.CardManagerresetCard with timeout: 0 (ms)
    --Waiting for card...
    ATR=3B EB 00 00 81 31 20 45 4A 43 4F 50 33 31 33 36    ;....1 EJCOP3136
        47 44 54 78                                        GDTx
    ATR: T=1, N=0, IFSC=32, BWI=4/CWI=5, Hist="JCOP3136GDT"
    => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00          ..............
    (146500 usec)
    <= 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65    o..............e
        01 FF 90 00                                        ....
    Status: No Error
    cm>  set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm>  init-update 255
    => 80 50 00 00 08 D4 AC DC F1 CA 9F 16 B9 00          .P............
    (158288 usec)
    <= 00 00 63 06 00 12 86 91 06 77 FF 01 42 16 4D 12    ..c......w..B.M.
        17 14 03 A1 1E 81 CF 9D A8 32 FA 34 90 00          .........2.4..
    Status: No Error
    cm>  ext-auth plain
    => 84 82 00 00 10 72 2C BF 47 F6 1C 73 AB 8A A5 B3    .....r,.G..s....
        AB 24 7D BF F7                                     .$}..
    (84620 usec)
    <= 90 00                                              ..
    Status: No Error
    cm>  card-info
    => 80 F2 80 00 02 4F 00 00                            .....O..
    (40529 usec)
    <= 08 A0 00 00 00 03 00 00 00 01 9E 90 00             .............
    Status: No Error
    => 80 F2 40 00 02 4F 00 00                            [email protected]..
    (45895 usec)
    <= 0C 4D 4D 61 74 63 68 65 72 41 70 70 6C 07 00 90    .MAppl...
        00                                                 .
    Status: No Error
    => 80 F2 10 00 02 4F 00 00                            .....O..
    (154165 usec)
    <= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00    ......SP........
        03 53 50 41 05 31 50 41 59 2E 01 00 01 0E 31 50    .SPA.1PAY.....1P
        41 59 2E 53 59 53 2E 44 44 46 30 31 06 A0 00 00    AY.SYS.DDF01....
        00 03 10 01 00 01 07 A0 00 00 00 03 10 10 06 A0    ................
        00 00 02 41 00 01 00 01 07 A0 00 00 02 41 00 00    ...A.........A..
        08 4D 4D 61 74 63 68 65 72 01 00 01 0C 4D 4D 61    .M....M
        74 63 68 65 72 41 70 70 6C 90 00                               Appl..
    Status: No Error
    Card Manager AID   :  A000000003000000
    Card Manager state :  OP_READY
        Application:  SELECTABLE (--------) "MAppl" 
        Load File  :      LOADED (--------) A0000000035350   (Security Domain)
         Module    :                        A000000003535041
        Load File  :      LOADED (--------) "1PAY."          (PSE)
         Module    :                        "1PAY.SYS.DDF01"
        Load File  :      LOADED (--------) A00000000310     (VSDC)
         Module    :                        A0000000031010
        Load File  :      LOADED (--------) A00000024100   
         Module    :                        A0000002410000
        Load File  :      LOADED (--------) "M"     
         Module    :                        "MAppl"
    cm>  /identify
    => 00 A4 04 00 09 A0 00 00 01 67 41 30 00 FF          .........gA0..
    (74848 usec)
    <= 51 04 01 24 47 45 42 34 50 48 35 32 32 44 01 03    Q..$GEB4PH522D..
        79 09 22 6A 82                                     y."j.
    Status: File not found
    FABKEY ID:   0x51
    PATCH ID:    0x04
    TARGET ID:   0x01 (smartmx)
    MASK ID:     0x24 (36)
    CUSTOM MASK: 47454234
    MASK NAME:   PH522D
    FUSE STATE:  fused
    ROM INFO:    790922
    COMBO NAME:  smartmx-m24.51.04.47454234-PH522D
    cm>  get-cplc
    => 80 CA 9F 7F 00                                     .....
    (74629 usec)
    <= 9F 7F 2A 47 90 50 15 40 51 51 58 24 00 63 06 00    ..*G.P.@QQX$.c..
        12 86 91 06 77 48 10 63 13 00 00 00 00 02 10 1C    ....wH.c........
        30 31 32 38 36 00 00 00 00 00 00 00 00 90 00       01286..........
    Status: No Error
      IC Fabricator                      : 4790
      IC Type                            : 5015
      Operating System ID                : 4051
      Operating System release date      : 5158 (7.6.2005)
      Operating System release level     : 2400
      IC Fabrication Date                : 6306 (2.11.2006)
      IC Serial Number                   : 00128691
      IC Batch Identifier                : 0677
      IC Module Fabricator               : 4810
      IC Module Packaging Date           : 6313 (9.11.2006)
      ICC Manufacturer                   : 0000
      IC Embedding Date                  : 0000
      IC Pre-Personalizer                : 0210
      IC Pre-Perso. Equipment Date       : 1C30
      IC Pre-Perso. Equipment ID         : 31323836
      IC Personalizer                    : 0000
      IC Personalization Date            : 0000
      IC Perso. Equipment ID             : 00000000
    cm>  delete |MAppl
    => 80 E4 00 00 0E 4F 0C 4D 4D 61 74 63 68 65 72 41    .....O.MAppl.
        70 70 6C 00                                      
    (207258 usec)
    <= 69 85                                              i.
    Status: Conditions of use not satisfied
    jcshell: Error code: 6985 (Conditions of use not satisfied)
    jcshell: Wrong response APDU: 6985
    cm>  delete |M
    => 80 E4 00 00 0A 4F 08 4D 4D 61 74 63 68 65 72 00    .....O.M.
    (56412 usec)
    <= 69 85                                              i.
    Status: Conditions of use not satisfied
    jcshell: Error code: 6985 (Conditions of use not satisfied)
    jcshell: Wrong response APDU: 6985Applet directory is:
    c:\Documents and Settings\Ieva\workspace\M\bin\M\javacard\MAppl.cap
    Best regards,
    Eve
    Message was edited by:
    Ieva

  • I need some help for an explanation. Loop for 1 minute.

              int minute=1;
              long currentTime=System.currentTimeMillis();          
              long stoppingTime = currentTime + (minute * 60 * 1000);
              while (currentTime<stoppingTime) {
                   // do x;
                   currentTime=System.currentTimeMillis();
              }I want to have the loop to run for 1 minute. It does not seem to work.
    What did I miss? I need some help for an explanation.

    Ran:
    class PrintTimeAsProcess {
      public static void main(String[] argv)  throws Exception {
        int minute=1;
        long currentTime=System.currentTimeMillis();
        long stoppingTime = currentTime + (minute * 15 * 1000);
        System.out.println("START Time: "+currentTime);
        while (currentTime<stoppingTime) {
          currentTime=System.currentTimeMillis();
        System.out.println("END Time: "+currentTime);
    }Got:
    START Time: 1149278202718
    END Time: 1149278217718
    1149278217718
    -1149278202718
    15000

  • Need some help...in need of a different way.

    Hi, I'm new to Java and need some help. I have 2 questions that are similar in nature.
    1st Question:
    In a program that I'm writting I have a do-while loop which at the end brings up a dialog box that asks the user to enter '1' for 'Yes' or '2' for 'No' to continue.
    I would rather have the option of having the user enter 'y' or 'Y' for Yes and 'n' or 'N' for No.
    Here is what I have currently:
    int x;
    String data;
    do{
    //Blah blah code
    data = JOptionPane.showInputDialog(null, "Enter 1 for Yes or 2 for No");
    x = Integer.parseInt(data);
    }while(x == 1);
    x++;
    2nd Question:
    In another part of my program I have a Case statement that asks the user to enter a number or a letter from a list of choices. They can enter '2' , 't', or 'T'.
    I would rather have all of this in an if-else chain. Is this possibe? if so, how would I do it.
    Thanks.

    I would rather have the option of having the user enter 'y' or 'Y' for Yes and 'n' or
    'N' for No. You can test the first letter of whatever the user inputs like this:String response = JOptionPane.showInputDialog(null, "Enter (Y)es or (N)o");
    response = response.toLowerCase();
    if(response.startsWith("y")) {
        // the user entered something starting with y
    } else if(response.startsWith("n")) {
        // the user entered something starting with n
    } else {
        // what are you going to do?
    }JOptionPane also has versions that would allow yes/no buttons. Eg, see:
    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html

  • Please I need some help with a table

    Hi All
    I need some help with a table.
    My table needs to hold prices that the user can update.
    Also has a total of the column.
    my question is if the user adds in a new price how can i pick up the value they have just entered and then add it to the total which will be the last row in the table?
    I have a loop that gets all the values of the column, so I can get the total but it is when the user adds in a new value that I need some help with.
    I have tried using but as I need to set the toal with something like total
        totalTable.setValueAt(total, totalTable.getRowCount()-1,1); I end up with an infinite loop.
    Can any one please advise on some way I can get this to work ?
    Thanks for reading
    Craig

    Hi there camickr
    thanks for the help the other day
    this is my full code....
    package printing;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.text.DecimalFormat;
    public class tablePanel
        extends JDialog  implements Printable {
      BorderLayout borderLayout1 = new BorderLayout();
      private boolean printing = false;
      private Dialog1 dialog;
      JPanel jPanel = new JPanel();
      JTable table;
      JScrollPane scrollPane1 = new JScrollPane();
      DefaultTableModel model;
      private String[] columnNames = {
      private Object[][] data;
      private String selectTotal;
      private double total;
      public tablePanel(Dialog1 dp) {
        dp = dialog;
        try {
          jbInit();
        catch (Exception exception) {
          exception.printStackTrace();
      public tablePanel() {
        try {
          jbInit();
        catch (Exception exception) {
          exception.printStackTrace();
      private void jbInit() throws Exception {
        jPanel.setLayout(borderLayout1);
        scrollPane1.setBounds(new Rectangle(260, 168, 0, 0));
        this.add(jPanel);
        jPanel.add(scrollPane1, java.awt.BorderLayout.CENTER);
        scrollPane1.getViewport().add(table);
        jPanel.setOpaque(true);
        newTable();
        addToModel();
        addRows();
        setTotal();
    public static void main(String[] args) {
      tablePanel tablePanel = new  tablePanel();
      tablePanel.pack();
      tablePanel.setVisible(true);
    public void setTotal() {
      total = 0;
      int i = table.getRowCount();
      for (i = 0; i < table.getRowCount(); i++) {
        String name = (String) table.getValueAt(i, 1);
        if (!"".equals(name)) {
          if (i != table.getRowCount() - 1) {
            double dt = Double.parseDouble(name);
            total = total + dt;
      String str = Double.toString(total);
      table.setValueAt(str, table.getRowCount() - 1, 1);
      super.repaint();
      public void newTable() {
        model = new DefaultTableModel(data, columnNames) {
        table = new JTable() {
          public Component prepareRenderer(TableCellRenderer renderer,
                                           int row, int col) {
            Component c = super.prepareRenderer(renderer, row, col);
            if (printing) {
              c.setBackground(getBackground());
            else {
              if (row % 2 == 1 && !isCellSelected(row, col)) {
                c.setBackground(getBackground());
              else {
                c.setBackground(new Color(227, 239, 250));
              if (isCellSelected(row, col)) {
                c.setBackground(new Color(190, 220, 250));
            return c;
        table.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
            if (e.getClickCount() == 1) {
              if (table.getSelectedColumn() == 1) {
       table.setTableHeader(null);
        table.setModel(model);
        scrollPane1.getViewport().add(table);
        table.getColumnModel().getColumn(1).setCellRenderer(new TableRenderDollar());
      public void addToModel() {
        Object[] data = {
            "Price", "5800"};
        model.addRow(data);
      public void addRows() {
        int rows = 20;
        for (int i = 0; i < rows; i++) {
          Object[] data = {
          model.addRow(data);
      public void printOut() {
        PrinterJob pj = PrinterJob.getPrinterJob();
        pj.setPrintable(tablePanel.this);
        pj.printDialog();
        try {
          pj.print();
        catch (Exception PrintException) {}
      public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
        Graphics2D g2 = (Graphics2D) g;
        g2.setColor(Color.black);
        int fontHeight = g2.getFontMetrics().getHeight();
        int fontDesent = g2.getFontMetrics().getDescent();
        //leave room for page number
        double pageHeight = pageFormat.getImageableHeight() - fontHeight;
        double pageWidth =  pageFormat.getImageableWidth();
        double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
        double scale = 1;
        if (tableWidth >= pageWidth) {
          scale = pageWidth / tableWidth;
        double headerHeightOnPage = 16.0;
        //double headerHeightOnPage = table.getTableHeader().getHeight() * scale;
        //System.out.println("this is the hedder heigth   " + headerHeightOnPage);
        double tableWidthOnPage = tableWidth * scale;
        double oneRowHeight = (table.getRowHeight() +  table.getRowMargin()) * scale;
        int numRowsOnAPage = (int) ( (pageHeight - headerHeightOnPage) / oneRowHeight);
        double pageHeightForTable = oneRowHeight *numRowsOnAPage;
        int totalNumPages = (int) Math.ceil( ( (double) table.getRowCount()) / numRowsOnAPage);
        if (pageIndex >= totalNumPages) {
          return NO_SUCH_PAGE;
        g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    //bottom center
        g2.drawString("Page: " + (pageIndex + 1 + " of " + totalNumPages),  (int) pageWidth / 2 - 35, (int) (pageHeight + fontHeight - fontDesent));
        g2.translate(0f, headerHeightOnPage);
        g2.translate(0f, -pageIndex * pageHeightForTable);
        //If this piece of the table is smaller
        //than the size available,
        //clip to the appropriate bounds.
        if (pageIndex + 1 == totalNumPages) {
          int lastRowPrinted =
              numRowsOnAPage * pageIndex;
          int numRowsLeft =
              table.getRowCount()
              - lastRowPrinted;
          g2.setClip(0,
                     (int) (pageHeightForTable * pageIndex),
                     (int) Math.ceil(tableWidthOnPage),
                     (int) Math.ceil(oneRowHeight *
                                     numRowsLeft));
        //else clip to the entire area available.
        else {
          g2.setClip(0,
                     (int) (pageHeightForTable * pageIndex),
                     (int) Math.ceil(tableWidthOnPage),
                     (int) Math.ceil(pageHeightForTable));
        g2.scale(scale, scale);
        printing = true;
        try {
        table.paint(g2);
        finally {
          printing = false;
        //tableView.paint(g2);
        g2.scale(1 / scale, 1 / scale);
        g2.translate(0f, pageIndex * pageHeightForTable);
        g2.translate(0f, -headerHeightOnPage);
        g2.setClip(0, 0,
                   (int) Math.ceil(tableWidthOnPage),
                   (int) Math.ceil(headerHeightOnPage));
        g2.scale(scale, scale);
        //table.getTableHeader().paint(g2);
        //paint header at top
        return Printable.PAGE_EXISTS;
    class TableRenderDollar extends DefaultTableCellRenderer{
        public Component getTableCellRendererComponent(
          JTable table,
          Object value,
          boolean isSelected,
          boolean isFocused,
          int row, int column) {
            setHorizontalAlignment(SwingConstants.RIGHT);
          Component component = super.getTableCellRendererComponent(
            table,
            value,
            isSelected,
            isFocused,
            row,
            column);
            if( value == null || value .equals("")){
              ( (JLabel) component).setText("");
            }else{
              double number = 0.0;
              number = new Double(value.toString()).doubleValue();
              DecimalFormat df = new DecimalFormat(",##0.00");
              ( (JLabel) component).setText(df.format(number));
          return component;
    }

  • Need some help with a remove function

    Design and code a program that will maintain a list of product names. Use a String type to represent the product name and an array of strings to implement the list. Your program must implement the following methods:
    Add a product to the list
    Remove a product from the list
    Display then entire list
    Find out if a particular product is on the list.
    You need to create a command command loop with a menu() function. The program must continue asking for input until the user stops.
    This is the assignment and this is what I have so far. I need some help writing the remove function.
    Thanks
    * Title: SimpleSearchableList.java
    * Description: this example will show a reasonably efficient and
    * simple algorithm for rearranging the value in an array
    * in ascending order.
    public class SimpleSearchableList {
         private static String[] List = new String[25]; //These variables (field variables)
         private static int Size; //are common to the entire class, but unavailable
         //except to the methods of the class...
         public static void main(String[] args)
              String Cmd;
              for(;;) {
                   Menu();
                   System.out.print("Command: ");
                   Cmd = SimpleIO.inputString();
                   if(Cmd.equals("Quit"))
                        break;
                   else if(Cmd.equals("Fill"))
                        FillList();
                   else if(Cmd.equals("Search"))
                        SearchList();
                   else if(Cmd.equals("Show"))
                        ShowList();
                   else if(Cmd.equals("Remove"))
                        Remove();
         //Tells you what you can do...
         public static void Menu()
              System.out.println("Choices..................................");
              System.out.println("\tFill to Enter Product");
              System.out.println("\tShow to Show Products");
              System.out.println("\tSearch to Search for Product");
              System.out.println("\tRemove a Product");
              System.out.println("\tQuit");
              System.out.println(".........................................");
         //This method will allow the user to fill an array with values...
         public static void FillList()
              int Count;
              System.out.println("Type Stop to Stop");
              for(Count = 0 ; Count < List.length ; Count++)
                   System.out.print("Enter Product: ");
                   List[Count] = SimpleIO.inputString();
                   if(List[Count].equals("Stop"))
                        break;
              Size = Count;
         //This method will rearrange the values in the array so that
         // go from smallest to largest (ascending) order...
         public static void SearchList()
              String KeyValue;
              boolean NotFoundFlag;
              int Z;
              System.out.println("Enter Product Names Below, Stop To Quit");
              while(true)
                   System.out.print("Enter: ");
                   KeyValue = SimpleIO.inputString();
                   if(KeyValue.equals("Stop")) //Note the use of a method for testing
                        break; // for equality...
                   NotFoundFlag = true; //We'll assume the negative
                   for(Z = 0 ; Z < Size ; Z++)
                        if(List[Z].equals(KeyValue)) {
                             NotFoundFlag = false; //If we fine the name, we'll reset the flag
              System.out.println(List[Z] + " was found");
                   if(NotFoundFlag)
                        System.out.println(KeyValue + " was not found");     
         //This method will display the contents of the array...
         public static void ShowList()
              int Z;
              for(Z = 0 ; Z < Size ; Z++)
                   System.out.println("Product " + (Z+1) + " = " + List[Z]);
         public static void Remove()
    }

    I need help removing a product from the arrayYes. So what's your problem?
    "Doctor, I need help."
    "What's wrong?"
    "I need help!"
    Great.
    By the way, you can't remove anything from an array. You'll have to copy the remaining stuff into a new one, or maybe maintain a list of "empty" slots. Or null the slots and handle that. The first way will be the easiest though.

  • Need to try to find Pi, need some help

    I have need to try to find some of the values of Pi,
    but when i try math.PI i only get down to like 8 decimals.
    I need some help.
    Not sure were to start either!
    Message was edited by:
    Aten

    You're just adding terms together. There's a series of them, so you need a loop. Each pass through the loop could add one more term. Note that each term has a denominator that is bigger by 2, and it's either added or subtracted (or to look at it another way, you're adding negatives alternately).
    The main issue is how accurate you want it to be. You can't add the digits together forever. So you have to choose a stopping point. You can stop based on a time period (when you've run out of time, stop adding new terms) or on precision (when two subsequent values are close enough to each other, stop).
    You'll probably want to use java.math.BigDecimal.
    If you give some more details about the assignment I can make some more suggestions.
    Why don't you give it a try and see how it works?

  • Need some help with GUI development

    Hi ppl.. I am new to labview and I am currently involved in a testing equipment development. I need some help. firstly I need to know if multi-screen GUI (with icons and stuff)is possible in Labview. Secondly I need to interface the measurements to a database. Would it be possible to create just small executable to perform the measurement part alone and do the rest of database operation using VB. (or would it be advisable to do the whole lot in labview)
    the final sft should look something like this
    screen1 :setup screen... interface with database
    screen2 :actual test and test results
    screen3 :log file creation
    measurement is via daq board and i also need to send some control signals and set up TCP/IP for data transfer.

    Hello.
    I am not completely sure what you mean by "multi-screen", but I am pretty sure that doing the user interface using a tab control will work for you. I have attached an example VI which is a state machine (which in LabVIEW you do with a case structure inside a while loop). Notice how the configuration controls are in the first page of the tab control, associated with state 0 of the state machine, but in the block diagram, they are actually used in state 1 of the state machine. Instead of writing a very long description, I will let you take a look at the code (which I saved in LV 7.0 version). Let me know if you have questions or comments
    Attachments:
    MultiScreenStateMachineExample.vi ‏50 KB

  • I need Some help to complete this program

    i write this program to call file from my hard drive "the file name is
    input.tex" "the program the file and the result for the program are below"
    please read the program and the file befor you read my question
    now, i need to use 3 arrays
    1) first array to read this part
    include[0]: VAR ZRO 1
    include[1]: +0000000000
    include[2]: VAR I 1
    include[3]: +0000000000
    include[4]: VAR SUM 1
    include[5]: +0000000000
    include[6]: VAR AVG 1
    include[7]: +0000000000
    include[8]: VAR N 1
    include[9]: +0000000000
    include[10]: VAR TMP 1
    include[11]: +0000000000
    include[12]: VAR DTA 990
    include[13]: +0000000000
    in this way
    VAR ZRO 1
    VAR I 1
    VAR SUM 1
    VAR AVG 1
    VAR N 1
    VAR TMP 1
    VAR DTA 990
    2) second array is dimensional array to read this part
    include[15]: READ N
    include[16]: LABL 20
    include[17]: READ TMP
    include[18]: GE TMP ZRO 40
    include[19]: SUB ZRO TMP TMP
    include[20]: LABL 40
    include[21]: PUTA TMP DTA I
    include[22]: LOOP I N 20
    include[23]: MOVE ZRO I
    include[24]: LABL 50
    include[25]: GETA DTA I TMP
    include[26]: ADD TMP SUM SUM
    include[27]: LOOP I N 50
    include[28]: DIV SUM N AVG
    include[29]: PRNT AVG
    include[30]: STOP
    in this way
    READ N
    LABL 20
    READ TMP
    GE TMP ZRO 40
    SUB ZRO TMP TMP
    LABL 40
    PUTA TMP DTA I
    LOOP I N 20
    MOVE ZRO I
    LABL 50
    GETA DTA I TMP
    ADD TMP SUM SUM
    LOOP I N 50
    DIV SUM N AVG
    PRNT AVG
    STOP
    3) the third to read this part
    include[32]: +0000000005
    include[33]: +0000000020
    include[34]: -0000000430
    include[35]: +0000000553
    include[36]: +0000001323
    include[37]: -0000000896
    in this way
    +0000000005
    +0000000020
    -0000000430
    +0000000553
    +0000001323
    -0000000896
    i hope i see some help
    [http://arbshare.net/files-182969.html]

    According to the file name ending with extension .tex, I guess that it's TeX, a markup language, not a programming language.
    Topicstarter: look for a more suitable forum. Good luck.

  • Need some help with Substring

    hi all
    i am writing a simple program and got stuck at one point
    this is how it goes:
    public static static main(String[] a) {
    for (int i=1; i<a.length; i++){
    System.out.print(a[i]+",");
    so if i entered "a ab abc" this becomes "a,ab,abc,"
    the problem is that i NEED to use substring to get rid of the last comma, how can i take the already print out result as a whole new string?? or i need to rewrite it in another way??
    i really need some help, thanks in advance
    B

    You start from index 1, skipping the first element in the a-array, is that what you want? Otherwise you should loop from 0.
    Anyway, here is how you can do it (skipping first element as you did):
    for (int x = 1; x < a.length; x++) {
      System.out.print(a[x]);
      if (x < a.length-1)
        System.out.print(",");
    }You can't remove what you have already printed out. Another way to do this, is with a StringBuffer:
    StringBuffer sb = new StringBuffer();
    for (int x = 1; x < a.length; x++) {
      sb.append(a[x]);
      if (x < a.length-1)
        sb.append(",");
    String s = sb.toString();
    System.out.println(s);

  • Complete Java n00b...need some help

    I'm very new to Java and I need some help writing a basic program.
    I need to write a program that lets the user add up an infinite amount of floating point numbers. The program should compute the sum of all the numbers entered thus far. So for example if the user enters 2 and 3, it should give a number of 5. If the user then enters 4, I should give me 9 etc.
    I'm not really sure how to get started on writing that. I can add up two numbers but I don't know how to tell the program to keep adding additional numbers to that sum. Can someone please help me out? thanks

    It's ok... it can be hard to understand even the simplest concepts with only text and no help.
    There needs to be an int variable outside (before) the loop initialized to 0.
    float num = 0;Next, you need to have an infinite loop that requests floats to add onto the number.
    Scanner input = new Scanner(System.in);
    while (true) {
        float toAdd = input.nextFloat();
        num += toAdd;
        System.out.println("Current sum " + num);
    }Putting all this together and putting it into a main method will work, but we have a bit of an issue. The program won't stop! For that reason, we need to specify a number which can exit the program. I like to use 0 for this purpose.
    Scanner input = new Scanner(System.in);
    while (true) {
        float toAdd = input.nextFloat();
        if (toAdd == 0) {    //test if toAdd is 0 so the program can break;
            break;
        num += toAdd;
        System.out.println("Current sum " + num);
    }So, this code will work:
    import java.util.Scanner;
    class AddNumbers {
        public static void main(String[] args) {
            float num = 0;
            Scanner input = new Scanner(System.in);
            while (true) {
                float toAdd = input.nextFloat();
                if (toAdd == 0) {    //test if toAdd is 0 so the program can break;
                    break;
                num += toAdd;
                System.out.println("Current sum: " + num);
    }Edited by: Arricherekk on May 18, 2008 3:19 PM

  • Error 1603: Need some help with this one

    When installing iTunes I first get an error box saying
    "Error 1406: Could not write value to key \Software\classes\.cdda\OpenWithList\iTunes.exe. Verify that you have sufficient access to that key, or contact your support personnel."
    The second one (after I click on Ignore on the last box) I get it this one:
    "Error: -1603 Fatal error during installation.
    Consult Windows Installer Help (Msi.chm) or MSDN for more information"
    Strange thing is that I do have full access to my computer (or atleast in all other cases I have had since I am the only one with an account on it).
    I have done my best in trying to solve it myself but I'm running out of ideas. I have downloaded latest versions from the website and tried installing Quicktime separately. I have also tried removing Quicktime using add/or remove programs though I just I didn't dare to take full removal because it said something about system files.
    Anyway I really need some help with this, anyone got any ideas?
    Greets,
    Sixten
      Windows XP Pro  

    Do you know how to count backwards? Do you know how to construct a loop? Do you know what an autodecrementor is? Do you know how to use String length? Do you know Java arrays start with index 0 and run to length-1? Do you know you use length on arrays too? Do you know what System.out.println does?
    Show us what you have, there isn't anything here that isn't easily done the same as it would be on paper.

  • Remote App on iPad connects but drops after about  20 mins. Need to turn  off wait about 1 minute then turn on wifi on iMac before it can reconnect. Need some help please.

    Remote App on iPad connects but drops after about  20 mins. Need to turn  off wait about 1 minute, then turn on wifi on iMac before it can reconnect. Need some help please.
    Already gone through troubleshooting guide a zillion times. Thanks.

    This worked for me... A little time consuming but once you get rolling it goes GREAT... Thanks....
    I got my artwork and saved it to my Desktop
    Opened up Microsoft Paint and clicked on "File" and "Open" and found it to get it on the screen to resize it
    Clicked "resize" and a box for changing it opened up
    Checked the box "Pixels" and "Unchecked maintain aspect ratio"
    Set Horizontal for 640 and Vertical for 480
    Clicked on "OK" and went back to "File" and did a "Save As" and chose JPEG Picture
    It came up "File Already Existed" and clicked "OK" (really did not care about the original artwork I found because wrong size)
    Went to iTunes and on the movie right clicked on "Get Info", clicked on "Details", then "Artwork"
    Go to the little box on the top left that shows your old artwork and click on it to get the little blue border to appear around it and hit "Delete" to make it gone
    Click on "Add Artwork" and find it where you put the one from above on your Desktop and hit "Open" and OK and your new artwork is now there and all good.
    Sounds like a lot of steps to follow but after around 5 or so you will fly through it. This worked perfect on my iPhone 6 Plus and I have artwork on my Home Videos now.

  • TS1702 I need some help the apps were downloading slowly

    The apps downloaded but it didn't cause it's stuck in downloading mode what should I do?
    The iOS 6 update didn't work.
    Please I need some help.
    The apps didn't download.
    Talking Angela and Ginger didn't download.
    Talking Santa didn't update.

    Try moving the existing backup file to a safe location so that iTunes has to create an entire new file.  The backup file is located here. You can delete that backup once you get a successfull backup.
    iTunes places the backup files in the following places:
    Mac: ~/Library/Application Support/MobileSync/Backup/
    Windows XP: \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    Windows Vista and Windows 7: \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\
    Note: If you do not see the AppData or Application Data folders, you may need to show hidden files (Windows XP,  Windows Vista and Windows 7), or iTunes may not be installed in the default location. Show hidden files and then search the hard drive for the Backup directory.

Maybe you are looking for

  • I am not able to download a game. says i am not compatible.

    Not able to download a game. Its bubble witch saga. Can anyone help?

  • BPM Trouble Shooting

    Need some clarification on the question below: <b> 1) Status in Transaction "SXI_CACHE" is not equal to 0.Which of the following would perform ? a) Check the condition of BP in IR. b) Acticvate the BP in "SXI_CACHE". c) Activate the BP in ID </b> Ans

  • Mac Indesign CS5 and Suitcase Fusion 3 "Universal Type Client could not open?

    Has anyone got any idea what I can do? I have CS5 and on launch of Indesign, I get the message dialogue box: Universal Type Client could not open the Font Vault at the location "". To access your fonts, please launch the Suitcase Fusion Core System P

  • Bizarre memory problems with os 10.2.8

    Hi there... i'm running 10.2.8 and have a problem! up until the other day i had around 3 gigs free... whilst my back was turned, my girlfriend scanned a bunch of images, and supposedly saved them on her hard drive via firewire. i'm not sure if that c

  • Fuji S5 raw

    The S3 is on the compatible RAW list, but the newer S5 isn't. The S5 is great, but the software it comes with is abysmal. I don't suppose anyone knows when the S5 might be added? or how long it usually takes to get new cameras added? Thanks Power mac