How can I "do nothing" for one of my expressions in an if-statement?

For instance:
if (s.nextInt() == 'z')
         return 0;
      else
         System.out.println("Please enter a 4 numbers:\n");
         System.out.println("First Number:\n");
         firstnum = s.nextInt();
         System.out.println("Second Number:\n");
         secondnum = s.nextInt();
         System.out.println("Third Number:\n");
         thirdnum = s.nextInt();
         System.out.println("Fourth Number:\n");
         fourthnum = s.nextInt(); 
         System.out.println("Press 'z' to exit");
         exit = s.next();
       }I want the user to enter 4 numbers and then press "z" to indicate the end of the list

The instructions clearly ask for you to do this for a variable number of inputs. i wrote your program for you because i was bored. Yeah yeah i know, i really shouldnt cheat you out of your education, but whatever.
    public static void main(String[] args) {
      Scanner thescanner = new Scanner(System.in);
      int nextint, min=Integer.MAX_VALUE, secondmin = 0;
      String next;
      System.out.println("Enter any amount of numbers. Enter 'z' when done.");
      while(true){
          System.out.println("Please enter a number");
          next = thescanner.next();
          if (next.compareTo("z")==0) break;
          nextint = Integer.parseInt(next);
          if(nextint<min){
              secondmin=min;
              min=nextint;
      System.out.print("Min is " + min + "; secondmin is " + secondmin);
    }If theres a better way to do it than getting the next as a string, checking it against z, and then parseInt-ing, someone should let me know.

Similar Messages

  • HT1349 how can i sign up for one to one if i didn't buy my ipad from an apple store

    i would like to purchase one-to-one for my new ipad, which i didn't purchase at the apple store.  how can I do that and is there any way I can use it this afternoon if the apple store near me has a slot available?  Thanks
    Betsy Wild

    Betsy, call the Apple store and see if you can get in if there is space available.  Friends have purchased Apple products and had no problems at the stores in my area participating.  One even went to a training session before buying.  So give them a call and get that spot before it is taken.

  • How can load properties file for one time and use in entire application

    Hi folks,
    I dont want to read properties file every time , and want to get property value in any servelet or jsp page.(means i want to read only property file only for once and want to get value in any where ) , how to do this.
    Message was edited by:
    RajeshwarReddyT

    means we have to read file every time Know but i dont
    want to be happen that ??? No you don't . You read the file once. You store it in the hashmap. Then you hand that hashmap to whatever class needing the data.
    getProperties() returns the hashmap, doesn't read the file.
    Maybe I should have called the method getMap or something.
    Message was edited by:
    karma-9

  • How can I get applecare  for my new iphone 4s living in a state where there is nor retail store?

    I purchased an iphone 4s for my mom who lives in Wyoming. I was told by Verizon that she could purchase AppleCare + via their 800 number in the first 30 days. She has been told she has to go to a retial store. Wyoming has no retail store. The closest store would be 7 hours away! There must be another option for her!

    She has now tried all those things and all insist she must go to a retail store. And then they try to sell her the regular Apple Care, which does not cover the two accidental replacements.  Pretty irritated with Verizon for mis-leading me and especially with Apple for not providing a way to purchase this at the time of purchase with the provider and compounding the problem by not having a mechanism in place for people who don't live near one of their limited locations. Poor customer service. Have learned my lesson.
    Thanks for the suggestions.

  • I have two users with different music on each itunes and i can only use one library, how do i use both for one iTouch?

    i have two users with different music on each itunes and i can only use one library, how do i use both for one iTouch?

    Chris, I believe this link may have the information you're looking for. Welcome to discussions!
    http://docs.info.apple.com/article.html?artnum=300432

  • How can I maintain more than one contact person for a supplier

    Hi
    As per our business requirement , How can I maintain more than one contact person for a single supplier in SRM?
    How these contact persons are supposed to log in to a portal with different user id and passwords and access the bids for same supplier.
    we are in SRM 7, and currently we are creating contact person throug customised BDC.
    please advice.
    Thanks & Regards
    NITIN
    Edited by: nitinkk on Sep 9, 2011 10:22 AM

    Dear Yaniv,
    Thanks for your information,
    I am able to create  users But my problem is How these contact persons are supposed to log in to a portal with different user id and passwords and access the bids for same supplier ? Is there any kind of maping is available for the user/ contact person to the supplier no.??
    Thanks & Regard
    NITIN

  • Hello how can i transfer photo for my old computer to the new one

    hello how can i transfer photo for my old computer to the new one

    If your computers are connected to the same network, you can turn on Sharing to allow you to see the contents of one from the other and do transfers. If there is no network, you can use "target disk mode" explained here: http://support.apple.com/kb/PH13842
    Otherwise, you will need to use external storage such as a USB flash drive.

  • I forgot my passcode lock for the ipod touch 4th generation. How can i make a new one?

    I forgot my passcode lock for the ipod touch 4th generation. How can i make a new one?

    If you cannot remember the passcode, you will need to restore your device on the computer that you Usually Sync with...
    http://support.apple.com/kb/HT1808

  • How can you transfer data from one ipod to another ?

    How can you transfer data from one ipod to another ipod ?

    The geniusbar told me what to do, I understood but there is still a problem for me >:/ It's not showing up though. Like "device."  Nothing is happening, and I tried as soon as I got home. Then after half an hour, then an hour, then 3 hours. My problem is that it's not showing up! It's stuck in recovery mode! There's still like 25% battery. So I have no idea why.

  • How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    Hi Nancy,
    This screenshot was only for imagination. A part of the code (not all) is below.  In the code there are some background images but they are not seem in live mode.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="css/my_site.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css"/>
    <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
    <style>
    #CollapsiblePanel1 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-color: #003366;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel1 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel1 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/international.jpg);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel2 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelContent {
        background-color: blue;
    #CollapsiblePanel3 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel3 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel3 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel4 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel5 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    </style>

  • How can I transfer information from one ipad to another?

    how can I transfer information from one ipad to another ?

    What kind of information? You can sync things like Contacts and Calendars by using iCloud. You can backup one iPad to iTunes on a computer and then sync the backup to the other iPad. You can configure your iTunes content and sync the same content to both iPads.
    It is based on what you want to do. Or are you looking for a way to send files from one iPad to another wirelessly? There are apps to do things like that, as well as cloud services, such as DropBox.

  • I have 3 podcast folders in my iTunes account, how can I combine them into one folder in my iTunes library?

    I have 3 podcast folders in my iTunes account, how can I combine them into one folder in my iTunes library?

    What is the title of the other bookmark folder that can not be deleted?
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * On Windows you can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac you can open Firefox 4.0+ in Safe Mode by holding the '''option''' key while starting Firefox.
    * On Linux you can open Firefox 4.0+ in Safe Mode by quitting Firefox and then going to your Terminal and running: firefox -safe-mode (you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    [[Image:FirefoxSafeMode|width=520]]
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Please report back soon.

  • TS3981 After migration files are now shared between two user accounts. How can I combine them into one account?

    After migration, from PC, files are now shared between two user accounts.I have to switch users to access files. How can I combine them into one account?

    See Pondini's  Transferring files from one User Account to another, for starters

  • Due to circumstances I have three iCloud accounts, How can I amalgamate them into one iCloud account?

    Due to circumstances I have three iCloud accounts, How can I amalgamate them into one iCloud account?

    No, unfortunately you cannot merge accounts or transfer any purchased content from one account to another. As I said Apple won't let you do that.
    See also here: http://support.apple.com/kb/HT5622?viewlocale=en_US
    I have multiple Apple IDs. Is there a way for me to merge them into a single Apple ID?
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.
    If you are wondering how using multiple Apple IDs relate to iCloud, see Apple IDs and iCloud.

  • How can I transfer apps from one iTunes library to another?

    How can I transfer apps from one iTunes library to another? My daughter has an iTouch, and I was managing it through my library. I have created an iTunes account for her, with a new iTouch, and would like to move the apps over. I tried to sync the old iTouch to the new library and it said it was already set up to sync with a different library. What is the best way to do this?

    You can transfer iTunes purchases by:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    To make the new computer the syncing computer you have to:
    - Transfer iTunes purchases lIke I described above
    - Make a backup of the iPod on that computer by connecting the iPod and then right-clicking on the iPod under Devices in iTunes and selecting Back Up.
    - Restore the iPOd from that backup
    She will have to continue to use your iTunes ID to update the apps prchased with your account. To use her account she will have to log into the computer with her account (iTunes>Store) and change the sign in on the iPod by going to Settings>Store.

Maybe you are looking for

  • Tex not sharp in DVD Sp

    Laetely I've been noticing the text I use (ie: buttons) is not sharp is there a fix for this? Was also wondering if the pre-built text in the pallete would be sharper than adding my own. G4 DP 1 GIG G4 laptop 1.25, MBP 2.0 1 GIG   Mac OS X (10.4.6)  

  • HP Pavillion Dv7 1279wm cpu upgrade to Intel Core2 Extreme QX9300 Technical Question.

    I made a royal error and posted this in the wrong topic first I apologize: So... I've kept great care of my laptop and it still boots fine (im obsessive about keeping it in tip top shape) but lately its age is becoming apparent and I'm not scared to

  • PSD overlay menu: text in anti-alias ?

    When creating a PSD overlay menu, should the character setting for anti-aliasing set to "none"? I read this in the User Manual, but the resulting text looks really ragged.

  • E430 - System shows only 2.5GB RAM, I have 4GB installed.

    Hello.  I have an E430 with Core i5 Ivy Bridge, 4GB RAM, onboard graphics. OS is Ubuntu 14.04 64-bit. No components have been installed or replaced since purchase. The problem is, system only shows I have 2.5GB RAM total. In BIOS it correctly shows 4

  • Locking clips, adding slideshows from iphoto to imovie and reverting clips.

    I have a few questions about imovie HD 6. 1. I am working on adding snips of video and pictures to my imovie project. However, I have several small clips that I want to add to a single audio clip. Is there a way to lock several video clips to my audi