Can't find the error on this small code :S

Hi , i've just compiled this code and i can't find what is wrong! :(
The compiler is ok, but the output print its not what i was expect.
If u insert 121 (capicua) the answer is: This number its not a capicua :S
what is wrong?
thanks!!
Note: Don't create another code plz.
import java.io.*;
public class Capicua {
     public static void main (String[] args) throws Exception {
          int digit, num;
          int inverted = 0;
               BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
               System.out.print(" Insert number: ");
               num=Integer.parseInt(br.readLine().trim());
               while(num > 0) {
               digit = num % 10;
               num = num /10;
               inverted = inverted * 10 + digit;
               if(num == inverted) {
                    // to be capicua the number inserted must
                    //be equals to the inverted
                    System.out.println("Its Capicua!");      
               }else{
                    System.out.println("This number is not a Capicua!");
}

Please use code tags (see button above posting box) when posting code. It makes it much easier to read.
So, it appears that capicua means palindrome--the number reads the same backwards and forwards. Is that correct?
There are ways of doing this without converting the 121 to a number, but I won't explain that unless you want.
I think your problem is this line:
if (num == inverted)
You have changed "num" within your while loop. Therefore, num is no longer the original input 121.
Try adding println statements like this to watch what happens:
while(num > 0) {
  digit = num % 10;
  num = num /10;
  inverted = inverted * 10 + digit;
  System.out.println("digit = " + digit);
  System.out.println("num = " + num);
  System.out.println("inverted = " + inverted);
}

Similar Messages

  • Ran hardware test and found error code 4SNS/1/40000001:YPOR-0.592 ? can't find the signification of this error code

    ran hardware test and found error code 4SNS/1/40000001:YPOR-0.592 ? can't find the signification of this error code.

    Back atcha!

  • When I click "about this mac" to check on my storage, I get a number of different sections music, movies, etc. but also I get a section called backups, where can I find the files in this section?

    When I click "about this mac" to check on my storage, I get a number of different sections music, movies, etc. but also I get a section called backups, where can I find the files in this section?

    Welcome to Apple Support Communities
    All the storage in "Backups" is taken up by local snapshots, which are made automatically in all MacBooks, MacBooks Pro and MacBooks Air with OS X Lion or newer and Time Machine turned on.
    See > http://pondini.org/TM/30.html I recommend you to leave them there, because they will be removed automatically. However, if you want, you can disable or remove them manually if you want, even if there's no reason to do this. Have a look at the link above for more information

  • I am a student who subscribed to the 9.99 photography package, I didn't realize there was a discount for students.  I would like to upgrade to the full package with the student discount.  I can not find the option for this. How do I do this?

    I am a student who subscribed to the 9.99 photography package, I didn't realize there was a discount for students.  I would like to upgrade to the full package with the student discount.  I can not find the option for this. How do I do this?

    Hi Djmontanalv,
    Please go through the link below.
    http://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html
    Regards,
    Anand

  • I can't put numbers on the decimals. It only allow ,00 as decimals. If i put 33.00 it's ok but i i put 33.44 when i press enter changes to 3344 as an entire number, i've try everything and can't find the solution. This should be a basic thing.

    I can't put numbers on the decimals. It only allow ,00 as decimals. If i put 33.00 it's ok but if i put 33.44 when i press enter changes to 3344 as an entire number, i've try everything and i can't find the solution. This should be a basic thing. How frustrating !!

    pedrofromsydney wrote:
    €          55,555.00
    that's the result i get. Still why can't i just type for ex. 29.55 and stay like that on the cell ? Why does it always change to 2955 or 2955.00. ??
    I don't understand this
    It appears you have the cell formatted to Currency, with the default two decimal places.
    What I don't understand, though is how Numbers arrived at a result of fifty five thousand five hundred fifty five on your entering the exact keystrokes in Yvan's post:
    an equals sign, followed by five ones, followed by a forward slash, followed by a 2.
    Here's the result I get:
    Could you do the following:
    Open a NEW Numbers document using the Blank template.
    Drag the Row and Column control (bottom right corner) to reduce the table to two columns and three rows.
    Enter the words "My table" in cell A1.
    Click on cell B2 to select it, then enter the formula 
    =11111/5
    Use only those eight keystrokes; do not include any commas, periods or other characters not shown.
    Click on B2 again to select it.
    Open the inspector and choose the Cell Format button.
    Do not make any changes in the Inspector window.
    Drag the Inspector window to the position shown in my screen shot.
    Take a screen shot that includes the Formula bar, the Table (with cell B2 selected) and the Cell Format Inspector pane (the same screen area as in my screen shot above).
    Post the screen shot in a reply to this post.
    I'm hoping there will be some clues as to what's happening here in the screen shot. Procedure for taking and posting a shot of part of the screen follows.
    Regards,
    Barry
    SCREEN SHOTS (Selected area)
    Place the mouse pointer at the top left corner of the area you want to include.
    Press shift-command-4.
    The mouse pointer will change to a plus sign on a circle.
    Hold down the mouse button and drag to the bottom right corner of the area you wan to capture.
    Release the mouse button.
    The screen shot will be saved to your desktop with the name "Picture 1" (The number will be different if you have taken other screen shots).
    POSTING
    In the Compose frame, place the Insertion point at the location you want the picture to be inserted.
    Click the camera icon above the compose frame to open the Insert Image dialogue.
    Click Choose file to open the Choose dialogue.
    If necessary, navigate to the Desktop and click on the 'by date column header to sort the files by date, most recent at the top.
    Select the most recent picture file.
    Click Choose.
    Wait for the picture's file name to appear beside Choose file.
    Click insert image.
    Done.
    B.

  • I purchased FrameMaker 10.0 Windows Upgrade License from FM9 and I can't find the download for this.

    I purchased FrameMaker 10.0 Windows Upgrade License from FM9 and I can't find the download for this.

    Get in touch with support if it doesn't show up on your Adobe account.
    Mylenium

  • Please help in finding the error in this code

    Dear Friends,
    I am trying to make the value of 'Shift' on the basis of  BLDAT CPUDT & CPUTM of MKPF but I am doing something wrong. Kindly have a look at the following code, especially the IF..ELSEIF section and help me in finding the error.
    Regards,
    Alok.
    SELECT MBLNR MJAHR BKTXT BUDAT BLDAT CPUDT CPUTM USNAM
    INTO CORRESPONDING FIELDS OF TABLE I_MKPF1
    FROM MKPF
    WHERE
    BUDAT EQ S_BUDAT AND
    TCODE2 EQ 'MFBF'.
    ********************************************************ALOK 01.02.07
    LOOP AT I_MKPF1.
           I_MKPF-MBLNR = I_MKPF1-MBLNR.
           I_MKPF-MJAHR = I_MKPF1-MJAHR.
           I_MKPF-BKTXT = I_MKPF1-BKTXT.
           I_MKPF-BUDAT = I_MKPF1-BUDAT.
           I_MKPF-BLDAT = I_MKPF1-BLDAT.
           I_MKPF-CPUDT = I_MKPF1-CPUDT.
           I_MKPF-CPUTM = I_MKPF1-CPUTM.
           I_MKPF-USNAM = I_MKPF1-USNAM.
    IF   ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
    AND   ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'A'.
    ELSEIF ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
       AND  ( I_MKPF1-BLDAT <>  I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'C'.
    ELSEIF ( ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
      AND  ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'B'.
    ENDIF.
    APPEND I_MKPF.
    CLEAR I_MKPF.
    ENDLOOP.

    Hi.
    IF (  I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
           AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'A'.
    ELSEIF  ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
    AND ( I_MKPF1-BLDAT <> I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'C'.
    ELSEIF ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
    AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'B'.
    ENDIF.
    Try the above code ..
    Regards
    Sudheer

  • Table in which RZ20 alerts are stored (Where can I find the error messages)

    Hi All,
    I want to know the table where i can see all the error messages poplulated as alerts in the TCode RZ20.

    hi,
    You can use the FM "BBP_GET_STATE_MONITOR" to get the avrious alert messages.
    BR,
    Disha.
    Do reward points for useful answers

  • ClassCastException -- Can't find the error

    i've searched through the forums regarding this error, and i can't pinpoint why i'm getting this error.
    i'm using a <jsp:useBean> tag with scope=application to declare a database connection pool. when the webserver starts, everything works fine for about 5 min, then i get the following error:
    java.lang.ClassCastException: DBConnectionPool
         at _0002faccount_0005flogIn_0002ejspaccount_0005flogIn_jsp_0._jspService(_0002faccount_0005flogIn_0002ejspaccount_0005flogIn_jsp_0.java:68)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    is my DBConnectionPool timing out? i KNOW the pool is working, since i'm able to access data in the DB for about 5 min. I could really use some help here. thanks everyone.

    thanks for the replies. here's the code in my login page:
    <!-- Connection Pool to User Database -->
    <jsp:useBean id="connPoolUser" scope="page" class="DBConnectionPool" >
         <jsp:setProperty name="connPoolUser" property="driver" value="interbase.interclient.Driver" />
         <jsp:setProperty name="connPoolUser" property="url" value="jdbc:oracle:thin:@ip:host" />
         <jsp:setProperty name="connPoolUser" property="username" value="user" />
         <jsp:setProperty name="connPoolUser" property="password" value="user" />
    </jsp:useBean>
    <!-- Connection Pool to Product Database -->
    <jsp:useBean id="connPoolProduct" scope="page" class="DBConnectionPool" >
         <jsp:setProperty name="connPoolProduct" property="driver" value="interbase.interclient.Driver" />
         <jsp:setProperty name="connPoolProduct" property="url" value="jdbc:oracle:thin:@ip:host" />
         <jsp:setProperty name="connPoolProduct" property="username" value="user" />
         <jsp:setProperty name="connPoolProduct" property="password" value="user" />
    </jsp:useBean>
    <jsp:useBean id="user" scope="session" class="User">
    </jsp:useBean>
    does it matter that i'm trying to declare 2 instances of the connection Pool? also, inside my pages that use the connection pool, i do the following:
    <jsp:useBean id="objConn" scope="page" class="DBConnection"></jsp:useBean>
    if (objConn.getConnection( connPoolProduct ) )
    perform my operations here
    sometimes, i also get an error:
    variable connPoolProduct undefined.
    wierd since it's an application variable. any suggestions?

  • I can't find the error

    It's coded correctly with it's opening and closing braces, why is it that line 19 indicating and error?

    Hi friend,
    Could you post your code ? We can't help you if there is no code. And which line is causing the error ...  Have you tried setting a  breakpoint  in the error class and stepping
    through each line in the debugger?
    Good day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Character Direction: where can I find the settings for this feature?

    Hi there,
    I keep getting an override in my Paragraph Style-menu saying: "Character Direction: Left To Right". It might have to do with the fact that I'm using styles that were created in CS3 - I'm using old .indd-files.
    Is this feature even mentioned somewhere in a menu or panel? Cause I've been looking everywhere and I'm getting slightly frustrated by now - even more because the Character Direction is in fact Left To Right as far as my eyes can see.
    How can I clear the override without having to use Alt+click?
    Thnx.
    Gijs

    That's my main issue with scripts, it should be easy, but somehow they hardly ever work for me.
    Did what you said and I got this error.If I don't select the text frame it will give me another error. If I select the text it doesn't do anything.
    Alt+click will do fine, don't worry. Thanx for the help though.
    Greetz,
    G

  • Scruber bar not scrubbing can't find the error

    hi all,
    if you notice anything that might be tripping up this
    scrubber code, I'd appreciate it if you could advise. I'm not able
    to write this direct, and painstakingly transcribed from a known
    source. It originally worked, but then I've changed some
    graphics...but instance names, positions, etc...are all good. The
    video object plays, and scrubber moves across the track I've
    created for it, but it's not responsive to mouse interaction.
    your help appreciated if you see anything. I've scanned it to
    the best of my ability.
    thanks,
    Pow_haaweeese
    my instance names:
    "loader_mc"
    is main movie clip containing loadBar and scrub handle
    "loadBar_mc"
    the loadbar movie clip of the bar graphic itself, separate
    from the containment stroke
    "scrub_mc"
    a simple handle that moves along, and should let me grab it
    code:

    Please use code tags (see button above posting box) when posting code. It makes it much easier to read.
    So, it appears that capicua means palindrome--the number reads the same backwards and forwards. Is that correct?
    There are ways of doing this without converting the 121 to a number, but I won't explain that unless you want.
    I think your problem is this line:
    if (num == inverted)
    You have changed "num" within your while loop. Therefore, num is no longer the original input 121.
    Try adding println statements like this to watch what happens:
    while(num > 0) {
      digit = num % 10;
      num = num /10;
      inverted = inverted * 10 + digit;
      System.out.println("digit = " + digit);
      System.out.println("num = " + num);
      System.out.println("inverted = " + inverted);
    }

  • Can anyone point the errors made on my code?

    I want to write a java Applet that implements a Graphical User Interface(GUI) from the the AWT package(not SWING package) to display a Pie Chart. The program should read a string from the user, then determine and display a Pie Chart that represents the percentage of vowels(a,e,i,o,u), consonants and others lettres in that string.
    This is just the interface design. I get an error where i set up the border for the TextArea, and I can only get the button and the TextArea to display is I add the "South" and "North" respectively, while the recganglt won't even show up. Why? Anyone?
    import java.util.*;
    import java.awt.*;
    import java.awt.Graphics.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.*;
    public class PieChart extends Applet implements ActionListener
         private PieCanvas canvas;
         Button pro;
         Panel buttonPanel;
         Color back, colorV, colorC, colorO;
         String c1, c2, c3;
         public void init()
              String in =getParameter("background");
              c1 =getParameter("vowelColor");
              c2 =getParameter("consonantColor");
              c3 =getParameter("otherColor");
              back =Color.black;
              colorV = Color.red;
              colorC = Color.yellow;
              colorO = Color.green;
              if(in!=null)
              back =Color.decode(in);
              setLayout(new BorderLayout());
              setBackground(back);
              canvas =new PieCanvas();
              buttonPanel =new Panel();
              setLayout(new BorderLayout());
              pro =new Button("Process");
              buttonPanel.add(pro);
              pro.addActionListener(this);
              JTextArea textArea =new JTextArea("This is an editable JTextArea " + "that has been initialized with the setText method. " +
                   "A text area is a \"plain\" text component, " +
                   "which means that although it can display text " + "in any font, all of the text is in the same font.", 5, 40);
    textArea.setFont(new Font("Serif", Font.ITALIC, 16));
              textArea.setLineWrap(true);
              textArea.setWrapStyleWord(true);
              JScrollPane areaScrollPane =new JScrollPane(textArea);
              areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              areaScrollPane.setPreferredSize(new Dimension(10, 50));
              areaScrollPane.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
              add("North", textArea);
              add("Center", canvas);
              add("South", buttonPanel);
         /*public void actionPerformed(ActionEvent event)
              if(event.getSource()==pro)
                   canvas.repaint();
                   canvas.shape="rect";
                   canvas.shapename="A Rectangle...";
                   canvas.shapecolor=c1;
    class PieCanvas extends Canvas
         public String shape="";
         public String shapename="";
         public String shapecolor="";
         public final int MAX_WIDTH = 300;
         public void paint(Graphics g)
              g.drawRoundRect(70,10,70,50,20,7);
              /*int x, y;
              if(shape.equals("rect"))
                   if(shapecolor!=null)
                        g.setColor(Color.decode(shapecolor));
                   else
                   g.setColor(Color.blue);
                   g.drawRect(MAX_WIDTH/4, MAX_WIDTH/4, MAX_WIDTH/2, MAX_WIDTH/4);
                   g.setColor(Color.white);
                   g.drawString(shapename, MAX_WIDTH/4, MAX_WIDTH/8);*/
    }

    Okay, let's go through Error Identification for Dummies.
    1. Compile the program. Does this produce error messages? If so, what are they?
    2. Run the program. Does this throw exceptions? If so, what are they? Post the stack trace.
    3. If it runs without exception, does it do what you want it to do? If not, what did you want and what did it do? Be precise.

  • Where can I find the batch no (or UPC code or Lot no) in the Delivery doc?

    Hi all,
    I am using 4.6c . I send the IDoc DESADV to my customer and they get the EDI document which their translator converts back to IDoc. I need to find this information in the delivery document (vl03n):
    lot no., batch no. UPC code. so that I can populate them in the outbound IDoc.
    I could find the batch no in the table LIPS in the field CHARG. and I know in the EDI, the segment is SLN where this information is stored, but where is this in the actual delivery document (and the outbound IDoc)?
    Please ask me if my question should be elaborated.. Hope you can tell me the tab and the field in the Delivery document (it could be at header or item level.)
    Thanks,
    Charles.

    Hi there Charles,
    Batch number is in DESADV IDOC in field E1EDP09 CHARG.  In VL03N, you can drill down into a line item, and go the the Batch Split tab to see this number.
    I don't believe UPC number is a standard SAP field.  There is a EAN (European Article Number) field which can be used like the UPC field if needed. 
    I have a case where a customer sends a UPC and lot number on their order, and needs to see it back on the EDI shipping notice.  I store these values in custom text fields, which pass from the order, back to the DESADV IDOC after delivery.  From there, I can include them in the EDI back to the customer.
    Regards,
    Aaron
    *Helpful?  Poins are appreciated

  • Where can I find the error log of adobe premiere CC

    Adobe premiere CC is doing very weird things this last month.
    When I open adobe I get a really weird setup. When I move everything back in order it's ok again. I save the new order under the same name (overlapping) but when I start adobe again, everything is messed up again.
    Than premiere is veeeeeery slowly when I output to adobe media encoder. Very slow in choosing the codec, change settings and Render Que.
    I even got a very strange and long error within adobe, but I closed it....
    I guess that error was the problem and I need to find it back again.
    Does adobe premiere create a log file where I can see that error from today again?
    Many thanks!

    And now I got this error.....

Maybe you are looking for