Got prob with if else

Hi, i'm a newbie to java and while i'm studying it, i got one problem with the code. Can you help me please because i don't know how to interpret correctly. I just know that when i excute and run it, then enter any number larger than 200, it still gimme the same result which is "you are ok". Here is the code:
public class IQ
public static void main(String[] args) throws Exception
int iq;
System.out.println("Enter your IQ number: ");
iq = (int)System.in.read();
if (iq > 200)
System.out.println("Abnormal");
else
System.out.println("you are ok");
}

Looks like a troll (there is no problem with if/else).
But if it's not a troll (and for the benefit of other n00bs).
The OP had int iq = (int)System.in.read();We look up the System class and find it containspublic static final java.io.Inputstream in;so we look up the InputStream class and see that int read() reads a single byte and returns it (or -1 for EOF). [Also int read(byte[]) returns bytes in the array passed.]
Maybe it's worth noting that the ascii values for '0' thru '9' is 48 thru 57.
If the user attempts to enter <1><0><7><Enter> then read() returns the ascii value for '1' which is 49 and the rest of the user input is discarded.
Now to the post made by PhHein.
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
int iq = Integer.parseInt(keyboard.readLine());We look up the InputStreamReader class and find that it converts byte[] to char[] (not strictly true, but that explanation will have to suffice in this context).
We look up the BufferedReader class and find that readLine() very handily reads until it encounters a line terminator (user pressed enter), and returns the input as a String.
We look up the Integer class and find that parseInt() gets the numeric value of a number stored in a String.
If the user enters <1><0><7><Enter> then readLine() returns a String containing "107" and parseInt() returns 107. Neat, eh.

Similar Messages

  • Got mixed up with someone else's account, please help!

    Alright guys, I'm sorry for the long post, but this is quite a complicated situation now and I haven't been able to get help anywhere else.  I talked to a Reddit user who happens to work for Best Buy Corporate, and he recommended asking one of the Community Connectors.  So here I am.
    Let me start with my original issue:
    Back when "Best Buy RewardZone" was still around, my mother had signed up for an account for my family to use. At the time, I wasn't yet 18 and therefore a parent had to sign up on my behalf. My mom never actually shops at the store, though... the only time she even goes there is if she's buying a gift for me or picking something up that I had put on hold.
    I'm now 23, meaning we've had this account for probably six years. Obviously RewardZone is now just called My Best Buy, but it's the same number, and we're still getting the bonus points.
    Up until about a year ago, the emails were still going to my mother's email, including the rewards certificate. I had created a free account for myself (not associated with any rewards account) in order to buy something back in 2007 or so (before we signed up for RewardZone), so I couldn't change her email address to mine - the system simply would not let me do that since my email already had an account.
    What I did in the meantime was just create a second email for myself and change her account's address to that. That way I was able to check it and get my reward certificates, and she wasn't bothered. But, the account was still in her name. Now that I'm older than 18, I should be able to get it in my name. We have the same last name - it's obvious that I'm not trying to scam the system or anything. I can understand if "Jane Doe" wanted to transfer an account to "John Smith" and the customer service rep wouldn't allow it because that's completely sketchy, but why can't two members of the same family shift around who actually owns the thing?
    Well, I noticed a few months ago that there was an option to link my account to a different My Best Buy number. So I put in my "mom's" ID, then logged into that account to confirm it. The result was basically two different logins that belonged to the same rewards account - however, the purchase history was still separate.
    So anyway, on December 30, my mom and I called the Best Buy customer service number. She explained the whole situation, and was told that they can't change the name on an account - only two letters. This seems a bit suspicious to me, because if they had typed in somebody's name wrong when they signed up, that person would basically be stuck with it forever...
    I explained that even though the account had my mother's name on it, I was the one who was making the purchases for the past couple years. I used my credit card or PayPal account, so they were all technically under my name. What the lady said I can do is create a new Member ID, and that somebody could transfer those purchases to my new ID, under my own name. She said that since I already had an account (which was now tied to my mother's ID), what she'd do is just delete my account and then I would sign up using that same email address, and this time not put in a member ID.
    I did that, and she said somebody would transfer the applicable purchases (basically all of them for the past year at least) to my "new" account.
    It's been almost 3 weeks now and so far, my account still has absolutely nothing in it. I do notice that purchases made with my account have been moved over to my mother's account... the completely opposite direction as I wanted.
    A more serious issue, however. I preordered the Meta Knight Amiibo figure (Best Buy exclusive) from the site back when it was still in stock. Obviously now it's completely sold out, because of the high demand. Because the order hasn't been fulfilled yet, it completely disappeared from both accounts. I still have my order confirmation email, with the order number, but cannot actually pull it up online to view the status.
    So I called back today and explained all of this. I was basically told "We can't transfer points, period. Whoever you talked to last time was wrong." Well that's great, now my account is completely empty, despite the hundreds of dollars of purchases I've made, because of someone's mistake? This needs to be fixed. The person I talked to today said he'd tie the Amiibo preorder back with my account "in 7-10 business days" as the other person said. I have to hope this guy is actually telling the truth this time.
    But what can I do to fix this problem?
    This was my situation a month ago. 
    Luckily the Meta Knight has arrived just fine, and I did get the emails updating the status for me.
    I since then contacted customer support via the website, and got an offer to merge the two accounts in my name.  But here's the thing... they combined the wrong account! I'm not sure why they thought the other account belongs to me, but all of the purchases were made at stores in Ohio, and I'm not from there. The address on file is somewher eI've never been. It's clearly someone else's account.  Oh, and my Gamer's Club Unlocked has completely vanished as well, which I was told wouldn't happen.
    So basically right now, when I log in with my email address, I get somebody else's member ID, somebody who happens to have an Elite Plus membership - but no Gamer's Club Unlocked.  I've made a couple purchases in-store, but I need some help fixing this problem as soon as possible.
    The only purchase I *know* was made with the older account (the member ID that was auto-created when the My Best Buy program was launched, probably?) is that Meta Knight order, and I still have all the emails with the order number if somebody can look it up and find what My Best Buy ID it was tied to.  I also have the second member ID, the one I created while on the phone with customer service - and the current (WRONG) one.
    You see how this is just one massive problem?  I want to solve one thing at a time, though.  If one of the Community Connectors is able to move accounts and memberships around, please let me know and I'll shoot you a private message with details.  My first priority is simply getting that Gamer's Club Unlocked membership back as I did pay for it and want to buy some more video games, but I've been holding off since I haven't been getting that discount.  I can worry about getting the stuff moved over from the account in my mother's name after that.
    Thanks

    Hi drfsupercenter,
    Thank you for taking the time to sign up for the forum and connect with us. 
    After reading over your post, I can definitely see how everything involved may seem complicated; however, I am confident that I can get everything straightened out for you.  There is no reason why you should have to call into us over and over again or wait week after week for a resolution.  The terms of the My Best Buy program are pretty direct, so I believe any level of frustration could have been avoided.
    A My Best Buy account (formerly Reward Zone) is intended to be used by a single member, and a member is not to share their account, benefits, points, or certificates with anyone else.  If the account was in your mother's name, then it should have only been actively used by her.  When it comes to merging multiple accounts the name on each account must be the same.  While there are occasions where we can change/alter the name on an account, we cannot completely change a name.
    I looked over your account history using the email address you registered with the forum and see that two accounts were merged a few weeks ago.  If any purchases you did not make were somehow merged with your primary account, then I should be able to remove them.  I would also suggest that we make sure the information associated with your account is up-to-date.  You do have an active Unlocked membership, so we may just want to have you relink your accounts (My Best Buy and BestBuy.com).
    I want to apologize for any inconvenience you have experienced, and I would like to gather some additional information and go over your My Best Buy account with you, so I will be sending you a private message.  To check your private messages, you will want to login to the forum and click on the little yellow envelope icon located at the top of the page.  I look forward to further speaking with you to see what I can do to help.
    How to Link a My Best Buy™ membership to your BestBuy.com Account
    I hope you enjoy the rest of your day.
    Derek|Social Media Specialist | Best Buy® Corporate
     Private Message

  • I Was trying to update my apps, then i got an alert that said sign in required. I pressed continue, then it took me to my acct settings and it said there was a prob with my previous purchase and I havent purchased anything???

    I Was trying to update my apps when i got a sign in required alert,
    i signed in and it took me to my account settings ]it said there was a prob with a previous purchase and i havent purchased anything?

    http://support.apple.com/kb/ht1808

  • I upgraded to the iphone 4S yesterday, ive got my contacts-apps-music back but I've not been able to figure out how to get my ringtones back? I purchased many tones with my 3G I assumed they would go back on my new one with everything else..

    I upgraded to the iphone 4S yesterday, ive got my contacts-apps-music back but I've not been able to figure out how to get my ringtones back? I purchased many tones with my 3G I assumed they would go back on my new one with everything else..

    The iPad is looking for a 4 digit passcode that you used to lock the device. Did you set a 4 digit code when you set up your iPad? You need to enter that code in order to unlock it. If you don't know the code, you will have to restore the iPad in order to unlock it.
    Read this for more information.
    iOS: Forgot passcode or device disabled - Apple Support

  • Similar probs to every1 else w/ iTurd 7.0, xcuse my sarcasm.

    Hey guess what guys? iTunes 7 wont install, can you believe that? I must be the only person in the world with this problem, cuz there is no one else on this board talking about this. Hmmmm. I'll outline my extremely unique problem here but tomorrow I'll just call the help line like every other idiot who got an ipod for xmas. I got mine three weeks before xmas but was too busy to bother with it til now and BOY am I glad, cuz now I can wait in line behind everyone else.
    got an ipod about a month ago, been dealing with this since. iTunes would not install because it says Quicktime will not install. tried gazillions of things including uninstalling QT and trying again, reinstalling QT and trying again. Yes I did the registry cleaning, windows installer cleaning, deleting all files to do with QT and iT.
    So then I went on a search of older versions of iTunes that did not come bundled with QT, thinking that if I could just get iTunes on my computer I could then update it and I'd be good. So I found iTunes5.0 and it installed. GREAT, huh?! I updated QT first to 7.0, which went off without a hitch (i never seem to have trouble with QT as a stand alone install). I went to update iTunes and nothing happens. So I download it again and try to install it over the 5.0. Same original error message from what now feels like a milennia ago. So I give up and say, hey, I'll just use 5.0, it seems fine.
    Hook up my brand spankin new video ipod and computer says "your ipod requires iTunes 7.0". Try updating several more times. Rebooting. Updating. blardy blar blah blah. Same probs as everyone else here it seems.

    The EXACT same thing happened to me. I have a 20G iPod w/ clickwheel. Tried all the 5 r's by myself, reinstalling itunes and then took it into the genius bar. they tried eevrything that i had--and luckily saw the iPod stall after about 500 songs. After nearly 2 hours and no solutions i had to leave. It was suggested that I try downgrading to the old iTunes version, which I did and now my iPod is COMPLETELY DEAD. the apple just keeps on turning on and off, can't restore, can't reset.
    What do I do? I am so upset--my ipod is older, off of warranty, but completely fine before I downloaded iTunes 7. I want to cry I am so frustrated and upset--will apple do anything about this? they killed my ipod w/ iTunes 7, the genius bar people haven't been able to do anything. Somehow it doesn't seem right for me to now have to get a new iPod.
    Any suggestions? Ways to get through to Apple w/out having to pay to talk to someone? Go back to the genius bar again? arggghhh.......

  • Hi all, I got problem with my Safari!?

    Hi all, I got problem with my Safari, same with Google Chrome, when trying to block pops-up. It's already ticked on BLOCK but everytime i click on new link, an annoyed pop-up appeared (game online, Mackeeper ...), any advice?

    There is no need to download anything to solve this problem.
    You may have installed the "Downlite" or "VSearch" ad-injection malware. Follow the instructions on this Apple Support page to remove it.
    Back up all data before making any changes.
    Malware is always changing to get around the defenses against it. In addition to, or instead of, the files listed in the support article, you may need to remove the following items:
    /Library/Application Support/dot
    /Library/LaunchAgents/com.dot.agent.plist
    /Library/LaunchDaemons/com.dot.daemon.plist
    /Library/LaunchDaemons/com.dot.helper.plist
    /System/Library/Frameworks/v.framework
    One of the steps in the article is to remove malicious Safari extensions. Do the equivalent in the Chrome and Firefox browsers, if you use either of those. If Safari crashes on launch, skip that step and come back to it after you've done everything else.
    If you don't find any of the files or extensions listed, or if removing them doesn't stop the ad injection, then you may have one of the other kinds of adware covered by the support article. Follow the rest of the instructions in the article.
    The problem may have started when you downloaded and ran an application called "MPlayerX." That's the name of a legitimate free movie player, but the name is also used fraudulently to distribute VSearch. If there is an item with that name in the Applications folder, delete it, and if you wish, replace it with the genuine article from mplayerx.org.
    This malware is often found on illegal websites that traffic in pirated content such as movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect more of the same, and worse, to follow. Never install any software that you downloaded from a bittorrent, or that was downloaded by someone else from an unknown source.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates
    if it's not already checked.

  • HT201365 how do i unlock a ipod 5th gen that has activation on it and i got it with a broken screen and repaired in now it asks for a icloud sign in

    how do i unlock a ipod 5th gen that has activation on it and i got it with a broken screen and repaired in now it asks for a icloud sign in

    There's no way around activation lock.  If you purchased this from someone else you'll have to contact them and have them remove it from their account as explained here: http://support.apple.com/kb/TS4515.  Otherwise you won't be able to use it.

  • Is there anything I can do for my iPod Classic that got washed with a load of laundry?

    Is there anything I can do for an iPod Classic that got washed with a load of laundry? Sincerely appreciate any feedback

    John,
    Needless to say, one would expect water damage as a result of a washer to be extensive.  That doesn't necessarily mean you have no chance of repair however.  I've seen and heard of a couple of do-it-yourself fixes and, if none of those help, you can always try sending it for repair.
    At home, I recommend trying...
    Leave the iPod in a bowl of uncooked (raw) rice.  Supposedly, the rice often absorbs the moisture in the surrounding area and, sometimes, from an electronic part.  Leave it for at least 24-48 hours.
    Leave the iPod in the sunlight for several hours.  When doing this, make certain to avoid direct sunlight as it may damage the unit.
    If all else fails, consider contacting a repair center.  Local is better but, if you have to ship it, contact them and explain your situation before you invest in shipping costs.

  • AV sync probs with digital out and dvds on X-FI

    anyone else having lip sync prob with dvds and digital out

    Well I guess the answer is "Nope"

  • MSI 538 - prob with firmware update

    I have seen that many had this same prob with this mp3 player.I tryed to update my ms-5538 and got message "Unidentified NOR Flash type".Set usb 1.1 nothing hapens, tryed other comps-same thing.Please help,what to do.  

    the links don't seem to be working properly at the moment, this is the file you need:
    http://us2.msi.com.tw/files/downloads/frm_exe/MS5538FW_v1.11.03.zip
    you can ignore the instructions in the ReadMe file. extract all the files in the zip, connect your 538 player (ensuring it is recognised and working correctly) and then run the FWISP.exe program file to update the firmware
    PS if your player is currently working fine with no problems then you do not need to update the firmware

  • Power Up probs with kt6 delta fis2r

    I've recently changed my mother board and given my kt6 delta fis2r to my dad. It came out of my comp in fine working condition (earthed when removing etc.) It's now in my dad's case and when it's switched on it immidiatly switches off again. The bios was updated to 5.5 but was working for weeks before being moved. Anyone have any ideas?
    Thanks in advanced.

    Just spoken to him, he's had the board out on the box connected it accross and it does the same, it's not actually getting far enough to give anything on the d-bracket. I've got a spare power supply here that isn't a Q-Tec and we're gonna try it on that first. My bro has also had probs this weekend so I'm told, he had a KT6V with the same power supply, and is now running my dads kt4 ultra. My bros PSU isn't liking my dad's comp either, so I'm now wondering if it's something to do with the 4 pin power plug on both PSU's? Still confused tho as I havn't had any probs with the board while it was on my Q-tec PSU, just lucky I guess?
    Thanks for all of the replies, I'll be changing my PSU asap.

  • The HP C4480 all in one series PRINTER that I got free with my i-Mac is printing TINY print despite that my computer is set at 13 font Helvetica. How to reset the printer to normal print?

    The HP C4480 all in one series PRINTER that I got free with my i-Mac is printing TINY print despite that my computer is set at 13 font Helvetica. How to reset the printer to normal print?

    Is the Paper Size: set to US Letter and Scale: set to 100%
    Dennis

  • Prob. with iTunes, Phone won't shut off.  Tks.

    3GS with 6.1.3 Prob. with iTunes.  When I want to close out of iTunes after a Podcast the App will not close out when I hit Home. All other Apps shut down, only prob. is with iTunes.  Cant turn phone off goes back ti iTunes when turned on again.  Tks.

    I hope the previous replies are wrong. It was my understanding that even when Match is turned off in iTunes, music previously matched or uploaded to iCloud will stay there, associated with my Apple ID, even through a cold boot etc. If you want to remove songs from iCloud, but keep them locally, do this:
    1. Click "Store" in the iTunes top Menu
    2. Select "Turn on iTunes Match" (if it isn't already turned on)
    3. Close iTunes.
    4. Hold down the Shift key while you open iTunes - this will prompt you to choose or create a (new, locally empty) Library in a different folder from your main Library.
    5. Now you should see ONLY music that is stored in iCloud.
    6. Delete them all. iTunes will show a checkbox or button for you to click to delete the selected items from iCloud.
    7. Turn off iTunes Match (see #1)
    8. Restart iTunes with the Shift key again, so you can get back to your main Library - with Match turned off.

  • TS3274 its almost 10 months,i purchased ipad2 32 3g wifi.itinially i got problem with applications shut off frequently now since last 4 months my ipad starts with a message (connect iTunes)like first time start and going to restore mode and it occurs freq

    its almost 10 months,i purchased ipad2 32 3G wifi.itinially i got problem with applications and safari shut off frequently now since last 4 months my ipad starts with a message (connect iTunes)like first time start and going to restore mode and it occurs frequently.plz advise.

    If you have followed the standard Apple troubleshooting processes (see user guide )
    probably a trip to the local Apple Store Genius bar is called for before warranty runs out
    Assuming the iPad has been released in your Country if not you may have to take it to a
    neighbouring Country where it is available
    This page will tell you ,via the drop down menu Countries that can support iPad
    http://support.apple.com/kb/index?page=servicefaq&geo=United_Kingdom&product=ipa d

  • How to share my iPad screen with someone else who is not on my network?

    I'd like to share my iPad screen with someone else who has an iPad and is connected to the internet, but not on my WiFi. Is this possible? Any apps that do this?

    Sorry, you can't do that unless they are on your LAN.  I don't know of any apps that will let you do it.

Maybe you are looking for

  • Error while attaching document to report on Portal - Invalid selection valu

    Hello All, We are running our reports on Portal and as per the business requirement the users have to create comments or attach documents to certain amounts in certain columns and once they create the comment a document icon shows up near that amount

  • Can no longer connect to Windows XP Home Network

    I recently upgraded to Mavericks and just noticed I can not longer connect to my Windows XP Home Network. Besides sharing files I also print through that network, but it's not just the printer that's afftected. In "Finder" I see the Home>Office Folde

  • How to downgrade from Windows 8 to Windows 7 g580

    hi i  would like to install Windows 7  instead Windows 8  in my g580.   there is some guide or how-to to can do it?  many thanks and sorry for my English

  • Data base oracle in SAP

    Hi, The combination of all dimension id's ideally make the primary(composite) key of the fact table. it seems that there is a database restriction of 16 fields to be combined to make a joint primary key. I heard that Oracle table join relation is the

  • Photoshop Album 3.0 Bilder speichern

    Hallo zusammen, wer bitte kann mir helfen:?? Ich finde nirgendswo die Information, in welcher Datei Photoshop Album die Fotos abspeichert, da es auch keine "Speichern unter.." Option gibt. Ich möchte das jeweils bearbeitete Album irgendwo sichern (an