Hi, i have a simple question

Hi all. New to the forums, and Java.
My question is probably very simple to all of you, but call me dumb, I just can't figure it out. I'm trying to figure out how to "check" an input so it is not 0. If it is, I want the program to use the while loop to prompt for a re-enter, and when it gets an input other than 0, the program continues. Here is the code:
import java.util.Scanner;
public class Assig1Ex1Ver2
   public static void main(String[] args)
      Scanner input = new Scanner(System.in);
      System.out.println("Type in the first number and hit \"enter\": ");
      double input1 = -1;
      double input2 = -1;
      if (input.hasNextDouble())
           input1 = input.nextDouble();
      else
           System.out.println("Entry of first number failed");
           System.out.println("The first number will be set to -1");
           input.nextLine(); // we must read what the user typed and then ignore it
      System.out.println("Type in the second number and hit \"enter\": ");
      if (input.hasNextDouble())
             if (input2 == 0);
                  while (input2 == 0);
                       System.out.println("Do not input 0. Please re-enter");
             else
                  input2 = input.nextDouble();
      else
           System.out.println("Entry of second number failed");
            System.out.println("The second number will be set to -1");
            input.nextLine(); // we must read what the user typed and then ignore it
      double answer = input1 / input2;
      System.out.println("The quotient is: " + answer);
}The "else" above "input2 = input.nextDouble()" for some reason is seen as an error (I guess that's my second question), but I if I omit that "else" I get this answer:
Type in the first number and hit "enter":
34
Type in the second number and hit "enter":
6
Do not input 0. Please re-enter
The quotient is: 5.666666666666667It's seeing the second input as always being 0. Anyone have an idea for this?

Ok, I rewrote it and got rid of the while statement.
import java.util.Scanner;
public class Assig1Ex1Ver2
     public static void main(String[] args)
          Scanner input = new Scanner(System.in);
          System.out.println("Type in the first number and hit \"enter\": ");
          double input1 = -1;
          double input2 = -1;
          if (input.hasNextDouble())
               input1 = input.nextDouble();
          else
               System.out.println("Entry of first number failed");
               System.out.println("The first number will be set to -1");
               input.nextLine(); // we must read what the user typed and then ignore it
          System.out.println("Type in the second number and hit \"enter\" (Do not enter 0): ");
          if (input.hasNextDouble())
               if (input.nextDouble()==0)
                    System.out.println("Cannot divide by 0.");
               else
                    input2 = input.nextDouble();
          else
               System.out.println("Entry of second number failed");
               System.out.println("The second number will be set to -1");
               input.nextLine(); // we must read what the user typed and then ignore it
          double answer = input1 / input2;
          System.out.println("The quotient is: " + answer);
}Now what happens is that after I push enter after inputting the second number, nothing happens. What's wrong now? Please help.

Similar Messages

  • Really?  All Adobe has for customer service is a forum?  I have a simple question.  Can't just contact someone?  Are you that cheap?

    really?  All Adobe has for customer service is a forum?  I have a simple question.  Can't just contact someone?  Are you that cheap?

    Not to be critical, but in the time you have waited to find out how to contact Adobe you probably would have had your question answered by someone here on the forum. Many times people have been given bad information when they have found a way to contact Adobe. Much of the so-called technical support has been outsourced overseas. And the people manning the phones have no experience with Adobe products. So you can complain some more. Or, you can ask your question. It's your choice.

  • How can I talk with someone? I have a simple question and it's not answered anywhere in the forums. I have asked it before and repetedly gets swept over

    Where do my files have to be in order to use creative cloud and not have my indesign links break? I'll need to use Indesign on different computers and my images won't be traveling with me... will I need to relink every image every time? this gets way too tedious after 5 pages of links are broken. Also,,, why do I need all these plugin's once I use an icloud version of indesign when I've saved the file on my external hard drive, and then open the exact same file from the exact same hard drive? The file never opens and is corrupt which means I have to rebuild the entire thing or physically travel back to that computer which has the indesign cloud.... It's baffling.
    And another question... how does adobe not have a live support number to call and ask questions? I've been in the same "click-loop" now forever  and I can't ever get to an actual useful forum.

    WesternJarhead wrote:
    Where do my files have to be in order to use creative cloud and not have my indesign links break? I'll need to use Indesign on different computers and my images won't be traveling with me... will I need to relink every image every time?
    Standard practice is to use File>Package and then save to drive/location that suits you. If you need it to travel with you bring the entire folder.
    The InDesign file will link to the folder where the Links folder is situated.
    WesternJarhead wrote:
    Also,,, why do I need all these plugin's once I use an icloud version of indesign when I've saved the file on my external hard drive, and then open the exact same file from the exact same hard drive? The file never opens and is corrupt which means I have to rebuild the entire thing or physically travel back to that computer which has the indesign cloud.... It's baffling.
    The file isn't corrupt. The Craeative Cloud version is a newer version than you have on your computer at home. That's why the plugins are missing, as older versions don't have the same plugins as the newer version of InDesign.
    If you want to work on a version created with CC - then you need to use file Export/Save and choose IDML - then open that in earlier versions of InDesign.
    However, you could install the Creative Cloud on your computer at home and use the same version of InDesign - this would solve  your problem without any extra work.
    WesternJarhead wrote:
    And another question... how does adobe not have a live support number to call and ask questions? I've been in the same "click-loop" now forever  and I can't ever get to an actual useful forum.
    InDesign has never offered user support in using the software. It's telephone and helpline service is not for that purpose. InDeisgn is a professional graphic designer/typesetter/whateveryourjob is tool.
    Like any tool you need to have specific training to it's end use, most people used to do an apprenticeship/trainee position going to college to learn the software and the fine principles of lithographic/screen/flexo/gravure printing and the use of images/text/graphics etc on the web.
    It's a professional's tool that requires professional training. Much like I wouldn't go out and buy a carpenters tool set and then complain that none of the tools do what I want them to do, like hammering in a screw.

  • New to Spiceworks and I have a simple question

    So yes I am new to spice works and maybe this is a stupid question but here it is. Spicerworksis installed and users are able to login and create tickets. We have AD intergration. But am I able to create a ticket for a user that has never used Spiceworks before. I was hoping that If I had to create a ticket for a user i could and Spiceworks would connect to the AD user. But instead if they never used Spiceworks it doesn't see them or allow me to enter their name. If any one could please tell what I'm doing wrong and how I can correct it.
    Thanks
    This topic first appeared in the Spiceworks Community

    The launch of Windows 10 signals a renewed focus by Microsoft on the mobile-enabled modern enterprise. With Windows 10 and SOTI, enterprise IT can take advantage of unified policy management and feature control, making it easier to manage the full breadth of devices across diverse use cases and lines of business. This Tech Note provides an overview of the key enterprise features of Windows 10 and provides insight into the policy management framework available in SOTI MobiControl for managing Windows 10 desktops, tablets, and smartphones.http://www2.soti.net/windows10technote?utm_source=SpiceWorks&utm_medium=Download&utm_content...

  • HT4910 I have a simple question or 2. 1) how can I see what is on my icloud and how do I edit the data if I do not want it on icloud. 2) I have an app that I would like to update data - it doesn't appear to be doing that, how can I fix that? It is the mob

    1) how can I see what is on my icloud and how would I edit the data that is on it?
    2) I am having problems with an app syncing data with pc - how can I fix that? It is mobile noter.

    Welcome to the Apple Community.
    You can see what's in iCloud collectively at settings > iCloud > storage & back up > manage.... You can only edit the data through the appropriate app (contacts, calendars etc)
    For problems with 3rd party apps, contact the developer.

  • A simple Question about % in CR Chart!

    Hi, I have another simple question.
    When i use SQL to storage data and wanna Crystal Report to display the data in chart using %
    which data type should i use?
    float or string?
    and I found when i use 0.12 as 12% in database , It could not display in Crystal Report line chart normally.
    What should I do??
    Please Help!!!
    Thank you VERY MUCH!!!

    If you have the datatype as string from your database then try adding the string field as a summary field in chart and select maximum instead of count and if you have them in number format then you can directly select the percentage in chart.
    Regards,
    Raghavendra

  • Simple question about JAVA path

    Hi. I have a simple question , but I spent several hours trying to find an answer.
    How do I know the location of the java executable which is used by Concurrent Manager.
    I already know that running which java under application user will not give me the correct answer

    Maybe you can try like this:
         public String getPath(){
              Class cls=getClass();
              String className=cls.getName();
              String packageName=cls.getPackage().getName();
              System.out.println(className);
              System.out.println(packageName);
              String newClassName=className.replaceAll("\\.", "/");
              String resouceName=newClassName+".class";
              System.out.println(resouceName);
              URL url;
              url=cls.getClassLoader().getResource(resouceName);
              String path="";
              path=url.getFile();
              return path;
         }

  • Hey just have a quick question that is ios7 coming on ipod touch 4g I heard that you guys didnt design ios 7 for ipod touch 4g so are u gonna design it or its never gonna come for ipod touch 4g

    hey guys just have a simple question that i heard that ios 7 is not gonna come for ipod touch 4 they didnt design it for ipod touch 4 so are you guys designing it or its never gonna come for ipod touch 4g.
    Thanks,

    As posted on Apples website since early June, the ipod touch 5th gen is the ONLY ipod that can handle ios 7.
    No other ipod has the required hardware.

  • Simple question - minimize application

    I have a simple question to nokia developers. Why I cannot minimize most of my applications in Nokia Asha 302? In Nokia E50 I could. Why are you going backwards in usefulness of your software?

    It is not going backward. Asha series is based on s40 OS while E-series on Symbian. s40 doesn't support multitasking while Symbian does.
    Please mark the post as solution if it solves your problem.
    Current Device - Nokia Lumia 1020/920

  • Simple question about mount and delay script

    Hello, I have a simple question about mounting volumes on start up.
    My computer wakes up auto - and then auto there are serveral applescript tasks (mount and start up programs)
    I use this script (daily) for serveral connections with external volumes I always need the connect to. ( In the script I use this code 3 times for other locations) I do this on start up.
    set Uname to "XXX"
    set Pword to "XXX"
    set someVolume to "afp://XXX.XXX.XXX.XXX/XXX/XXX
    mount volume someVolume as user name Uname with password Pword
    (same code for 2 other locations)
    When i do this on start up sometimes the script says there is no connection possible. I guess it's because on start up the connection isn't there. And 1 minute later when computer is total ready the connection is ok. When I run the script then It works. Just sometimes ( In the morning) 'It' want to connect but the script stops. When i do it manually(I run the script again) it works just fine.
    Is it possible that I need a delay? Can someone explain this?
    How would I make a delay handler for this script? Is that the best solution?
    Thanks in advance. This is something small i'm wondering about.
    Colin

    BTW, If you saved the script as an application +(and not as an application bundle)+ you could drop the script on to *Drop Script Backgrounder* (freeware).
    Then the script would run in the background, so, you wouldn't see it running in the Finder.
    <http://www.macupdate.com/info.php/id/7922/drop-script-backgrounder-x>
    Tom

  • Simple Question - Data Import

    Hi,
    i have a simple question. Is it wise to change our actual import scenarios for input data from systems out of sap to XI?
    Today we have the scenario that data from outer systems will send per ftp to a special directory. After that a report will transform the data into a batchinput. The btci will send per rfbibl into the system. Now we have a huge number of such reports. Will it now be better to change to XI, which we use perhaps for MDM?
    Xi could take the file from ftp-srever maps the fields an will send per bapi to sap.
    Is it a quite simple scenario or is batchinput still the better way.

    Hi,
    If you have a scenario where you have different file formats , which needs to be converted and then send to different systems based on some conditions , then suggested is XI usage.
    However, also if you already have XI installed and running for the MDM system , then you can think of routing all messages through XI.  It may make sense to use one system for all routing and data conversion puposes.
    Hope this view helps.
    Cheerio,
    Disha

  • SIMPLE QUESTION - EXTERNAL iSIGHT CAMERA

    I just have a simple question...
    I was using an older iMac G5 with an external iSight camera and just upgraded to a new 24" iMac. Can the external iSight camera still be used on an iMac with a built-in camera?
    The cable with the external camera allows for more flexible viewing capability.

    Hello rgarros50
    The second part of your question is not quite so simple.
    Plug your external iSight in and turn it on. If you like, you can use the suggestions from How to test your (external) iSight to ensure it is functional to be sure it is working with your new iMac.
    The answer to your question about the "default camera" depends on which application you are using to operate your iSight. Here is how camera selection works in a few example:
    (1) For iChat, you can choose which iSight you use in the "Camera:" choices bar in iChat > Preferences... > Audio/Video that appears when more than one compatible camera is connected. Although your camera choices will be different, the choices bar will look something similar to the Preferences settings shown here:
    Most other applications also have settings that allow you to choose which camera to use. However, they do not all work the same way.
    (2) For instance, iMovie's camera choice is NOT set via Preferences. When you have more than one compatible camera connected, iMovie uses a drop-down menu choice something like this (depending on which version of iMovie you use):
    Note: Because I have no built-in iSight, when my external iSight is disconnected, the drop-down menu shows only "Time Lapse." Because your iMac has a built-in iSight, your built-in iSight will show in the drop-down menu even when no other camera is connected. Connecting your external iSight should allow you to choose either camera.
    (3) Photo Booth is such a simple, basic app that it offers no menu selectable choice. Unless you make your built-in iSight the camera being used by some open application before you launch Photo Booth, Photo Booth will use ONLY your built-in iSight.
    However, you can use the trick from ¶ 4 of http://docs.info.apple.com/article.html?artnum=302781 to let Photo Booth use your Firewire external  iSight:
    • Connect your external iSight and turn it on.
    • Quit Photo Booth (PB) if it is running.
    • Launch any app with a user-selectable camera "Preferences..." menu command.
     (The "tip" suggests that you use iChat, but others should work as well.)
    • Open "Preferences..." and set the camera "Preference" to use your built-in iSight.
    • Now launch PB. PB should now use the external iSight
     because your built-in camera is in use by the other application.
    (4) For apps other than those above, see their Help or other documentation.
    EZ Jim
    PowerBook 1.67 GHz w/Mac OS X (10.4.11) G5 DP 1.8 w/Mac OS X (10.5.2)  External iSight

  • A simple question about performance!

    Hi! I have a simple question about performance. Suppouse that you have a servlet or a class with DB access, and you need to use a value several times in that page. What is best, to assign the value from say, a resultset or a request.getParameter() to a variable or to call the resultset or the request every time you need to retrieve that value? Which option uses less memory, which is faster, etc.?
    Hoping the best fou u
    Raul

    If you need more values from a db, the best is to open some connections (connection pool) and use the for accessing the db.
    To get the data only once, open the connection, get the data, store the data whereever you want: variable (class), hidden control (if you want to send from one page to another by request) and close the connection as quicky as possible.
    The advantage of the first method is that the most time consuming activity (connections opening) is done only once.

  • Moving Final Cut Project to External Hard Drive...Simple Question!

    I'm new to Final Cut, Macs and External Hard Drives and have a simple question:
    I've created a project in Final Cut. I would like for Final Cut to be stored on my mac, but all project/media files to be stored on the External Hard Drive. Which files do I move to the hard drive and what settings to I have to change for Final Cut to be able to locate them?
    Many thanks!

    Well, you should always store the Application and the project file on your main OS drive. And yes, always have an external for the media. In FCP, open the SYSTEM SETTINGS in the FCP menu and you will see the interface for setting your Capture Scratch disk.
    The files you move default to the DOCUMENTS folder, and are in the FINAL CUT PRO DOCUMENTS. The Capture SCRATCH, RENDER and AUDIO RENDER files.
    Do yourself a favor and glance at that manual...or the FCP tutorials. This is FCP basics 101.
    Shane

  • Simple Question - desktop folders

    I have a simple questions about moving Desktop Folders - when I move the folder into the HD, to exactly where I want it among my many folders, there is a copy that stays on the desktop. I then start saving things to one or the other, and they do not update together. The result is two half-full folders, one of which refuses to leave the desktop when I try to move it. Why does this happen, and how can I avoid this without just deleting one and possibly loosing info?
    PowerBookG4   Mac OS X (10.4.8)   Combo drive, 768 MB memory, 1.33 processor

    where is you user account? is it a network user? or local? is the HD the same as the system disk?

Maybe you are looking for

  • A/R Credit Memo -  Applied Amount

    In A/R Credit Memo (ORIN), how do we find out what 'Applied Amount' consists of? Is it all open A/R invoices? I compared that number to the BP open A/R invoices but the number doesn't add up.

  • HP Officejet 7680 print issue alignment/ black ink problem

    My printer is playing up again - this time it keeps trying to align, and fails (according to the readout on the screen) . The black ink is also not working at all (trying new cartridge).  I suspect the two issues are connected? When I tried to print

  • Photo Stream Events and Organization

    I have been organizing my iPhoto library and after getting my iPhone I am having some trouble understanding Photo Stream. I take pictures with my iPhone and I see them show up in events in iPhoto (such as Oct 2011 Photo Stream). Are these pictures on

  • How to hide linked slides in PDF docs in Keynote?

    Well... I want to make a CV (Curriculum Vitae) that should be for the German rules with max two pages. And I would like to make a keynote with two pages and 20 hided linked pages and sent it in PDF. Because... if the person that is reading the docume

  • Switch iPod Classic from PC to a Mac

    Hi, I recently dowloaded ALL of my music/videos (nearly 33 GB) to my new 80GB Classic iPod using iTunes 7.5 on my Windows Vista. I am now getting rid of the Windows and switching over to a Mac. I know that I must reformat my iPod in order for it to c