Scanner in else if is not reading correctly

The scanner doesnt seem to read the second time in the else if statement.
it just automaticly assigns y the previus value i read in.
import java.util.*;
public class test
  public static void main(String[] args)
    Scanner in = new Scanner(System.in);
    int x = in.nextInt();
    while(x != -1)
      if(x == 0)
        System.out.println(x);
      else if(x == 1)
        int y = in.nextInt();
        System.out.println("x " + x);
        System.out.println("y " + y);
      else
        System.out.println("YO!!");
      x = in.nextInt();
Output:
1
3
x 1
y 1there is a way i sorta figured out to fix this by putting a print or println before I read in.
any idea why this is happening?

maybe its just the compiler then i just tried it on jcreator

Similar Messages

  • Not reading correctly?

    I just got a 4th Gen Nano for Christmas, etc.
    I have another video Nano registered to my computer and don't have a problem with it. However, when I plug this new iPod into the USB to register it, nothing happens except a window pops up with the folders/contents of my E: Drive. Apparently it's not reading it correctly, but how can I fix this so I can use my new iPod?
    I have the current version of iTunes installed and I'm running on Windows XP.

    The problem has something to do with "iPodService Module has encountered a problem and needs to close". I read another thread somewhere about it, but their problem seemed to be stemming from Norton. I'm using avast! antivirus.
    I've tried uninstalling/reinstalling iTunes.
    I still had no idea what's wrong. .-.

  • D20 memory not reading correctly. Bios sees only 20 gigs lenovo diagnostic sees 24 gigs

    Ok i have a d20 with one set of dimms not reading in the bios.  I have tried using all combinations and it always disables one channel of one CPU not reading in the bios but if I use the lenovo diagonstic it sees all the memory and can also run the quick memory test with no errors.  I would really like to get all of the slots to work anyone got an answer for this.  Thanks for you help in advance.
    Mike

    I'm assuming you're following the correct DIMM install order based on the service label on the inside cover?  The DIMM numbering is non-standard with regards to the location.
    If you think you've narrowed it down to a specific DIMM slot (or pair of DIMM slots), I'd try booting the system with memory ONLY installed in that slot (or slots).  Obviously it's not the recommended fill order or anything, but it could be a good test to see if you possibly have a damaged slot or something.
    Also, have you been messing with the CPUs at all?  Though unlikely, I would guess it's possible that a specific CPU pin in the socket could be damaged as well.

  • 970A-G45 with latest Bios not read correctly By Amd Overdrive

    System is as follows
    Motherboard: 970A-G45 Bios is now 1.61 all have been tried
    CPU: AMD FX 8120
    Memory: AMD Performance Edition 1600MHz 8 gbyte
    PSU Corsair GX600
    problem is that AMD BEMP profiles are grayed out,With this processor and memory the BEMP profile should be available both AMD and Patriot the makers of the memory say the problem is the bios not being read correctly by AMD overdrive.Now how do we get a bios release that will be correctly read by AMD Overdrive.here are pics of cpu-z and AMD overdrive BEMP.
    I used the instructions posted here  but the image in the instructions doesn't show either
    http://img593.imageshack.us/img593/6560/cpuz1x.jpg
    http://imageshack.us/content_round.php?page=done&l=img651/1912/cpuz2j.jpg
    http://imageshack.us/content_round.php?page=done&l=img41/2338/amdoverdrivebemp.jpg
    ok the links work now had to resize images

    Does AMD overdrive start and work on your system, besides the BEMP thing: yes!, so that is not the question or problem here.
    Do you have the hardware components that are needed to support BEMP: NO!
    Quote
    AMD Black Edition Memory Profile –feature is available with the following, validated memory modules:
    Vendor:   Part #:   Supported CPU Models:
    Corsair   CMD4GX3M2B1600C8   965BE (C2), 955BE, 720BE
    Corsair   CM3X2G1600C6GT   965BE (C2), 955BE, 720BE
    Corsair   CMG4GX3M2A1600C6   965BE (C2), 955BE, 720BE
    Corsair   CMG4GX3M2B1600C7   965BE (C2), 955BE, 720BE
    Mushkin   996657   965BE (C2), 955BE
    Mushkin   996601   965BE (C2), 955BE
    OCZ   OCZ3BE1600LV2G   965BE (C3), 955BE
    OCZ   OCZ3BE1600C8LV2G   965BE (C3&C2), 955BE
    Patriot   PGS34G1600LLKA   965BE (C3&C2), 955BE
    Patriot   PGS34G1600ELKA   965BE (C3&C2), 955BE
    Patriot   PGS34G1333LLKA   965BE (C3&C2), 955BE
    Patriot   PGS34G1333ELKA   965BE (C3&C2), 955BE
    In addition the system must meet the following requirements in order to enable the Black Edition Memory Profile feature:
    790FX, 790GX or 790X AM3 motherboard with BEMP compatible BIOS revision
    AMD Phenom™ II AM3 Black Edition CPU
    In any case, this is a pointless discussions.  I point to the specific parts on the AMD site that have to do with "BEMP" and you ignore that and point to AMD Overdrive stuff, which not necessarely includes BEMP support unless the hardware conditions are properly fullfilled.
    Contact:
    - AMD Support
    - MSI Technical Support
    ... and Patriot support, this time mentioning that your neither have a "790FX, 790GX or 790X AM3 motherboard" nor an "AMD Phenom™ II AM3 Black Edition CPU".

  • Small size file can not read correctly on other linux

    Hi, I am running archlinux 0.8 on my laptop, and there is another linux runs kernel version 2.6.20 with root filesystem of debian v3.1.
    I wrote a shell script which reads a small, 49 bytes, only 1 line conf file on my archlinux, it works fine.
    But if I copy script & conf files to debian, the script can not read conf file with:
    while read f;do; echo $f; done < conf
    but `cat`,`more` commands can read it. I have to open conf file with vi on debian and do nothing but :wq rewrite it to make script working.
    Both arch & debian use ext3 file system. Could anyone tell me why? thanks.

    I think your command is wrong: it works with zsh and doesn`t work in bash. Maybe you should remove extra ';'?
    while read f;do echo $f; done < conf

  • Lightroom not reading correct data for Lens and Camera Serial Number

    Hi you all.
    Recently got Lightroom, and I'm so impressed - I never imagined image organizing and adjustment could be this easy and at the same time very advanced.
    I have a problem, however. Lightroom (and Adobe Bridge, too) does not correctly read the EXIF data of Lens type and Camera Serial Number.
    The first ~50 images I took and imported turned out correctly and displayed my serial number and lens (18-55 mm Canon) inside Lightroom.
    But now, whenever I import photos into Lightroom or view them with Bridge, they all display "Unknown Lens" and "Unknown Camera Serial Number".
    At first I thought that maybe the camera didn't correctly record this data on to the photos anymore for some reason, but a comparison using EXIFToolGUI shows that the metadata is EXACTLY the same as in the photos that display this info in Lightroom correctly.
    I have not done any changes to either my camera (Canon EOS-350D / Digitial Rebel XT) or lens (the kit lens, 18-55 mm Canon).
    It seems that for some reason, Lightroom has stopped reading these two fields of metadata - all the other fields, such as aperture and shutter speed, all display correctly.
    I also tried to reimport the photos into Lightroom, but it didn't help. Neither did "Synchronize Folder" -> "Scan for metadata updates".
    What should I do? I'd like my lens information do display correctly, as I'll buy a new lens soon.
    I have attached one of the photos that Lightroom doesn't read the data correctly from. Try importing it into your Lightroom, and see if how the info displays.
    Thanks in advance.

    Are these jpgs or RAW?  I have only edited metadata on jpgs.
    It looks like Vista's import stripped out all the makernotes.  I didn't look at your file but that seems to be what happened.  Be warned, Photoshop CS2 also strips out makernotes!
    Now how to fix the problem.  If you want to edit the metadata on files already loaded into LR, you need to write out your metadata to the files first, then edit the metadata, then read the new metadata into LR.  This is scarey for me, so I always make sure my backup is up to date on the images first.
    What to do...  You probably can't put back all of the makernotes, so what to do to get the lens information in.  I don't know if putting back in the makernote LensType would trigger LR to reconsider its lens information.  I don't know.  If it had a real lens name, my guess would be no because it would have an XMP::Lens field which would override.  But maybe unknown lens doesn't have this field and it would re-read the makernotes.
    The other solution is to forget about makernotes for these images and put the exact text you want into XMP::Lens.  I think that's the "easy" way.
    In either case, you will have to become familiar with exiftoolGUI or exiftool itself.  I use the command line exiftool but it looks like you can edit multiple files with exiftoolGUI.  Select your files, click the edit thingy (^) under XMP, choose various, and there is lens.  Put in the text you want.
    I would do this with one file first.  If the lens shows up after you read the new metadata into LR, you know you have it right.
    Note, exiftool can write backup files for each file.  This makes too much of a mess for me.  I prefer to copy the directory first (I have copies anyway, I just have to make sure the backups are up to date).
    Good luck!  I'm struggling with a similar situation where the same lens used by two different cameras is coming out with a different name.  I need to go back and "fix" the names in the images already imported, and then develop my procedure for setting a single unique name before I load new images into LR.  Not too much of a problem because I'm loading in GPS information anyway...  What's another call to exiftool...
    Judy

  • Trimmed Quicktime Time code Media Files not reading correctly in CS5+ (works in CS4).

    I'm using Prores footage with metadata Timecode inserted into the Quicktime file.  Then I edit the Quicktime file, click "Save" and then import the trimmed file into APP CS4.  CS4 recognizes the edited clip and displays the timecode correctly (adhearing to the trims made on the file with Quicktime).
    BUT, in CS5, when I use the SAME clips, the timecode displays what the untrimmed timecode on the trimmed image.  So now, my timecode is OFF. 
    Really want to figure out how to fix this.  Does CS6 fix this issue?  Is there a preference or custom setting I need to select in order to have CS5 adhere to the metadata stored in the Quicktime file's timcode information?
    Any help would be greatly appreciated!

    There is a difference between Save and Save As in QuickTime Player. When you Save after trimming, the trimmed data remains in the file and takes up the same amount of space as before. When you Save As, the trimmed data is not included and you end up with a smaller file.
    I don't know why CS5 is behaving differently but it's more efficient to Save As and it will solve the CS5 problem too.

  • StreamTokenizer NVAL bug? 16 digits not reading correctly?

    hi all!
    i do some calculations which are highly precise, and we use numbers with 16 digits after the comma. this works most of the time without problems. but for some numbers java rounds it automatically. i think the problem is within the StreamTokenizer nval method.
    but please see the code to get what i mean:
    private static void readFromFileTestNumberProblem() {
              try{               
                   FileReader reader = new FileReader(new File("test.txt"));
                   StreamTokenizer tokenStream = new StreamTokenizer(reader);
                   //recognize end of lines as separated tokens. ttype will be set to TT_EOL
                   tokenStream.eolIsSignificant(true);
                   tokenStream.nextToken(); // get the first token
                   String flag = (String) tokenStream.sval;
                   while(flag.equals("START")){
                        System.out.println("------------------------");
                        for (int i = 0; i < 5; i++) {
                             if(tokenStream.nextToken() == tokenStream.TT_NUMBER){
                                  System.out.println((Double)tokenStream.nval);
                             else throw new Exception("Check Input File - Not " + nObjectives + " Objectives in line " + tokenStream.lineno());     
                        // check for END token...
                        if(tokenStream.nextToken() == tokenStream.TT_WORD){
                             if (tokenStream.sval.equals("END")) {
                                  flag = (String)tokenStream.sval;
              catch (Exception e) {
                   e.printStackTrace();
         }and a file to test it: save it into test.txt
    START 7106199.0 5.0376 0.5068132912149117 0.8624999999999999 225450.0
    7595899.0 4.764800000000001 0.6378176973051516 0.9624999999999999 281000.0 END
    result is:
    7106199.0
    5.0376
    0.5068132912149117
    0.8624999999999999
    225450.0
    7595899.0
    4.764800000000001
    0.6378176973051516
    0.9625 --> i dont like this value :-) it should be 0.9624999999999999
    281000.0
    is this a bug in nval? or is this normal?
    if it is normal, can someone tell me how can i get around this...
    would appreachiate any help ..
    thanks
    thomas

    that does not change anything..
    private static void readFromFileTestNumberProblem() {
              try{               
                   FileReader reader = new FileReader(new File("test.txt"));
                   StreamTokenizer tokenStream = new StreamTokenizer(reader);
                   //recognize end of lines as separated tokens. ttype will be set to TT_EOL
                   tokenStream.eolIsSignificant(true);
                   tokenStream.nextToken(); // get the first token
                   String flag = (String) tokenStream.sval;
                   tokenStream.wordChars('0', '9');
                   while(flag.equals("START")){
                        System.out.println("------------------------");
                        for (int i = 0; i < 5; i++) {
                             tokenStream.nextToken();
                             System.out.println(tokenStream.toString());
                        // check for END token...
                        if(tokenStream.nextToken() == tokenStream.TT_WORD){
                             if (tokenStream.sval.equals("END")) {
                                  flag = (String)tokenStream.sval;
              catch (Exception e) {
                   e.printStackTrace();
         }same result as before..
    7106199.0
    5.0376
    0.5068132912149117
    0.8624999999999999
    225450.0
    7595899.0
    4.764800000000001
    0.6378176973051516
    0.9625
    281000.0

  • Thermocoup​le not reading correctly using SCC-TC01

    We have set-up several thermocouple inputs that are conditioned by SCC-TC01.  These are professional grade thermocouples of type J and K.  It appears that the the readings from the thermocouples is incorrect (-1.15 mV at room temperature).  This means the temperature it is reading is negative.  We tried switching the positive and the negative, but the reading is still negative.  The gain through SCC-TC01 appears to be 100 so we tried to correct the measurement that way, but it does not seem to work (we tried multiplying and dividing by different powers of 10).  We thought that maybe the thermocouples were faulty, but using new did not correct the problem.  We have been successful in using the same data acquisition board in measuring other signals such as for load cells, so this problem with the thermocouples is puzzling.  When we increase the temperature around the thermocouple it also does not appear to respond as significantly as it should.
    Thanks,
    Rob Jackson

    Hi Rob,
    You mentioned that the offset voltage you had to provide in your program changed each time you started the VI, and indicated that this was possibly due to changes in ambient temperature. This would be compensated by the CJC sensor, which is built into your SCC-TC01. Since MAX does not allow you to select the built in CJC Sensor, the SCC may be configured incorrectly, possibly due to the SCC-TC01 being assigned to the incorrect port or some other mistake. You did not mention in your previous post the results of going through the quick start guide and ensuring the configuration is correct.  This would be a helpful trouble shooting step. Since the device is for signal conditioning, if the configuration is off, the resulting data will be off.
    You had also mentioned that you are using the “new” LabVIEW routines. If you are referring to programming with DAQmx instead of Traditional DAQ, this will not be a concern. In MAX, where the test panels are being run, it does not matter if you were using DAQmx or DAQ, since the test panel is looking at the actual hardware.
    I hope that this helps. Please let me know if you have any further questions I can clarify or if this solution does not take care of your missing VI issue. Thanks-
    Mallori M
    Mallori M
    National Instruments
    Global Customer Education Program Mananger
    Calculate the time you will save with NI Training

  • DVD not read correctly: Medieval 2 will not start anymore (original disc)

    Hi everyone, sorry if i am posting this in the wrong part of the website but i really need help with something. I bought a new pc game ( Medieval 2 Total War ) and when i 1st installed it, it worked fine. The day after i went to play it again and when i clicked on the icon the DVD Drive started and the disc was being read. The problem was though an Error message came up saying that i needed to insert the right disc when it clearly stated on the manual disc 1 was to kept in the drive. Can anyone tell me why it was working 1 minute then the next saying that my disc does not exist please? I tried to reinstall it and everything but the same message appears over and over. Any suggestions please?
    Thanks in Advanced
    David

    Hello David
    It will be interesting to know which notebook model you have.
    By the way: try to disable packet writing software DLA. Maybe it helps.
    The procedure of changing a setup of DLA is as follows:
    1. Open Windows Explorer
    2. Right-click the icon of the CD/DVD drive and choose Properties
    3. Click the DLA tab
    4. To disable DLA option clear the Enable DLA on your drives checkbox
    Please let me know if this works.

  • Annotations are not read correctly

    Hi, I have the following sample Annotation
    package annotations;
    import java.lang.annotation.Annotation;
    * @author Stefan Schuster
    * TODO To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Style - Code Templates
    public @interface NoticeAnnotation {
         String name() default "anonymous";
         String note() default "TODO";     
    And the following class that uses the annotation:
    public class AnnotationsTest {
         public static void main(String[] args) {
              for(Method m : AnnotationsTest.class.getMethods())
                   if(m.isAnnotationPresent(NoticeAnnotation.class))
                        // Die Annotation ist vorhanden, auslesen des Methodennamens und
                        // der Parameter der Annotation
                        System.out.println("Die Methode " + m + " ist mit einer Notiz versehen:");
                        NoticeAnnotation na = m.getAnnotation(NoticeAnnotation.class);
                        System.out.println("Der Entwickler " + na.name() + " hat eine Notiz eingef�gt:");
                        System.out.println(na.note());
         @NoticeAnnotation(
              name = "Dagobert Developer",
              note = "Diese Methode muss noch verbessert werden"
         public void testMethode()
              // not relevant
    The problem is that the annotation is not found for any method, so the
    part where the information about the annotation is printed is never called.
    What am I missing, to me it looks like the sample from the annotations tutorial,
    but it is not working...
    Thanks in advance,
    Stefan

    Add @Retention to your annotation:
    import java.lang.annotation.*;
    @Retention(RetentionPolicy.RUNTIME)
    public @interface NoticeAnnotation {
        String name() default "anonymous";
        String note() default "TODO";
    }That directs the JRE to read the annotation into memory at run time, so it can be found by reflection.
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/class-use/Retention.html
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/RetentionPolicy.html

  • Pdfs are not reading correctly

    I use indesign and illustrator CS6 and when I write a pdf my client says its showing up as funky black and white and not color. Is there something wrong with my software?

    Also, how are you creating the PDF. I am assuming it is from ID that has included graphics from Illustrator, but did you use the Illustrator tools or print to the Adobe PDF printer (the Acrobat tool)? What options did you select on the creation tool?

  • Issue with battery in settings (not reading correctly)

    I am very disappointed in battery life but I am getting NO help from the interal battery meter on the.  Any solution from Samsung or Google on this?  Check out the screen capture to see what I mean...  Says Discharging and is showing wrong info...

    Turn the device off then plug it into the AC outlet until it shows it's full.  Unplug the device then turn it on.  Plug it back in and let it charge.  Make SURE in the battery settings it is showing up as Charging(AC) and not Charging(USB).  If it says Charging(USB) and it's plugged into an outlet then your cable is faulty.
    Ironically both my GSM and LTE versions came with bad usb cords.

  • Modbus DSC point not reading correctly

       I'm using LV 2013 32bit on W7-64bit.  I'm talking to an industrial controller using Modbus over Ethernet.  My current software uses the DSC modbus interface, in which I define the Modbus bus itself within a library in the project, then define each Modbus point as an address inside that modbus definition.  Inside LabVIEW, you can then get to the Modbus data via Shared Variables.  I am currently using the dynamic shared variable calls, rather than static shared variables.  I have points that are Boolean (coils) and Reals, with some Read Only and some Read/Write.  In general, all of this works.
       However, there is one Read/Write Real that acts funny.  If I set it to a new value or if the industrial controller sets it to a new value, the industrial controller gets the new value.  The shared variable engine on my computer even gets the new value, as can be verified by opening the Distributed System Manager.  But LabVIEW continues to read the old value, with no errors.  Other Read/Write points work fine, and I've looked over the address definition several times and can't find any reason why this point should be any different than the others.
        Does anyone have any ideas why the DSM can see a new value of a shared variable, but LabVIEW continues to get the old value?  I've looked at the init case for the dynamic SV's, and I can't see any options there that I can tweak to try to resolve this.  My next attempt will be to rewrite the entire sub-system so that it uses NI's latest Modbus library and skips the whole DSC thing.  That will probably be much better for other reasons as well.  I've noticed that with DSC and Shared Variables, the first time the program runs it gets started pretty quickly, but subsequent runs can take up to two minutes to connect to all the SV's.
    Thanks,
       DaveT
    David Thomson Original Code Consulting
    www.originalcode.com
    National Instruments Alliance Program Member
    Certified LabVIEW Architect
    There are 10 kinds of people: those who understand binary, and those who don't.
    Solved!
    Go to Solution.

    Sorry, I can't help you in this case.  The config error was within my own software configuration.  I was just telling it to do the wrong thing.  Nothing that could be useful for anyone else.
    I hope you figure out your issue.  I know how maddening that can be.
    DaveT
    David Thomson Original Code Consulting
    www.originalcode.com
    National Instruments Alliance Program Member
    Certified LabVIEW Architect
    There are 10 kinds of people: those who understand binary, and those who don't.

  • Parallel LED circuit not reading correctly

    Good day,
    Can anyone tell me if there is something wrong with this circuit or if the software is acting funny?
    I have a voltage source positive going into 3 parallel circuits.  Each circuit contains a 30 ohm reisiter connected in series to 3 parallel LED's.  The LED's have a forward operating current of 20mA.  
    the first branch is reading 1.9V the second branch is reading 2.2V and the third branch is reading 3.4V across the parallel LED's.  
    hoping it is a bug I introduced or maybe I am misunderstanding how to connect the components properly.  
    I have a file with a cap screen to show how it is connected
    Attachments:
    multisim circuit.doc ‏138 KB

    1. Please create .png files from your screenshots and insert them directly into the post. The little Tree icon in the toolbar just above the text box where you type your message inserts images. Some people on the Forum will not open attachements in other file formats.
    2. Real LEDs have different voltage drops for different colors due to different chemical composition. Also the parallel LEDs (at least real ones) would have slightly different VI characteristics so that each of the three LEDs(of the same color) would have different currents and, thus, different light output.
    3. It is not clear what your intention is. Normally LEDs are connected in series so that the same current flows through each (same color). Rather than fixed resistorrs use some king of current regulating circuit to adjust the current in each series string to get your RGB effects. Note that you will have very little "headroom" between the source (V1) and the series string of blue LEDs (~10 V).
    Lynn

Maybe you are looking for