App termination loop

Type the end-of-file indicator to terminate
*On UNIX/Linux/Mac OS X type d then press Enter
*On Windows type z then press Enter
new to java and i cant figure out how to code this, i tried using a while but i keep having clashing types in thepublic double minimum3 Scanner inputs,
been trying this today
double num1;
double num2;
double num3;
String z = "z";
          Scanner input = new Scanner(System.in);
               System.out.println("to terminae pogramon UNIX/Linux/Mac OS X type d then press enter");
               System.out.println("on windows type z then hit enter to exit");
if (input.next() = "z")
System.exit(0);
else
               System.out.println("enter first number");
               num1 = input.nextDouble();
               System.out.println("enter second number");
               num2 = input.nextDouble();
               System.out.println("enter third number");
               num3 = input.nextDouble();
my program goes fine until trying ti implement tat bit of a loop any ideas?

First and perhaps most importantly you almost never want to compare objects using == (String is an Object).
When you use == with objects you are comparing Object references. This will only return true if the two references are both pointing to the same object.
Instead you should use the equals method to compare Objects (like Strings) for equality.
Second I am not entirely sure what you want but if you want to have a while loop that executes on multiple possible conditions you could do something like this instead...
public void myMethod(){
   String aString = // read from user
   while(!validTerminator(aString)){
     // stuff
public boolean validTerminator(String aString){
  if(aString.equals("z")){
    return true;
  return aString.equals("d");
}

Similar Messages

  • Family Sharing Approval of App keeps Looping

    I have my son and daughter setup for Family Sharing. My son has requested for two apps from his iMac (OS 10.10). On My iMac (also OS 10.10) I have selected one notification and have hit "APPROVE' button. It prompts me to sign in to purchase the app (Although it is a FREE app $0.00) and already has my ICLOUD username defaulted in grey, but prompts for ICLOUD password.  I enter this and select OK - it keeps repeating this prompting for the password.
    I have confirmed I have the correct password by logging into he accounts section of my ICLOUD account via System Preferences.
    I have tried the 2nd notification, and also asked him to send a new one (third) request through - but the same 'looping' upon selecting APPROVE/DECLINE occurs.
    Per above, I have also attempted to DECLINE the request, but it also prompts for my ICLOUD Password repeatedly.

    No, did not find a solution, but the looping stopped - it may have been on one set of requests - I'm not really sure.
    I am having other issues with Family Sharing request - notifications don't appear on all devices and once approved they app is not loading on requestors device etc.   Great concept but its harder than it needs to be at the moment.

  • Access Java app message loop from ActiveX control running in JNI

    Anyone know how to access a Java application's message loop from inside JNI code?
    Through the (JNIEnv *env) or (jobject obj) parameters maybe?
    I've got an ActiveX dll that I'm running via JNI. The ActiveX dll creates an IP server on a separate thread. When another process connects to the IP server I need to PostMessage (MS Windows term) from this IP server thread to the thread that the Java application is running on.
    It appears the Java application's message loop is not present / available in the JNI code and consequently the message is never posted from the IP thread to the JNI / Java App thread.
    Of course I can manually add a message loop to the JNI code and the PostMessage works just fine. But then the message loop is executing and the Java application is effectively blocked and becomes unresponsive because the JNI method call never returns as its busy running this while loop doing a GetMessage --- DispatchMessage inside the ActiveX dll.
    Maybe JNI is not really intended or this purpose and it's just not possible?
    Thanks.

    Hi Charbs, thanks for the reply.
    I've done a bit more investigation, my application doesn't display any content if I set wmode to direct, even when I try and play a very simple .swf that in no way will be using stage3D.
    I'm now assuming that setting direct wmode forces the .ocx to attempt rendering using Direct3D regardless of whether I use any Stage3D or not.  It would be interesting to find out if it is possible to set wmode to direct, and disable any use of Direct3D, although I suspect that setting wmode to direct would at least use Direct3D as its viewport regardless of any type of display generated by the swf.
    I will investigate the Event.ERROR suggestion, but I'm not a Flash/AS programmer at all, I wouldn't know wher to start so this might take a while - unless any of you helpful souls might knock something up to output/log any error messages from a simple stage3d swf?
    Also, I suspect that how I currently capture the display output and then transfer that to my own Direct3d texture/surface might not be compatible with how direct mode works.  Is there any in depth  technical documentation for how the ocx or projector handle direct wmode?

  • Messed up my default apps (terminal, AppStore, preview, etc)

    I bought a refurbished MacBookPro. I noticed it started going slow, and there were a slew of programs I didn't want on my computer.  I figured I would try to look up jpegs on "this mac" to see if i could delete some stuff to make the computer run a little faster. I ended up deleting about 2,000+ files that were from the old user. I could see profile pictures from Target employees, old work documents, a bunch of stuff that I didn't know would even still be on a refurbished computer. I decided to delete these files. Shortly after that, I noticed that my PhotoBooth, Preview, Updates, and worst of all, my Terminal, as well as the AppStore, Word, Adobe, etc, wouldn't even open or respond to a command. You click on the icon, it flashes open, then automatically closes. I didn't think deleting these random files would affect necessary mac applications. I'm wondering if there's anything to do to fix this rookie mistake. I've tried to reset PRAM, and and access the terminal to redownload the default apps, but I can't do that because they won't open. I also can't delete these as they're required by the system. I can't watch videos on YouTube, can't look at photos, can't edit pictures (under preview). I'm pretty much at a loss. Everything I've read about repairing these apps requires the terminal. I don't need to be reminded of how ******* stupid this was to do. I also don't have the option to use a time machine backup. Thanks ahead of time.

    Do a backup. Boot to the Recovery Volume (command - R on a restart or hold down the option key during a restart and select Recovery Volume). Run Disk Utility Verify/Repair and Repair Permissions until you get no errors.  Then re-install the OS.
    OS X Recovery
    OS X Recovery (2)

  • WDA app keeps looping

    Hi,
    For some reason a WDA app. i've set up via the WDA iView keeps looping.
    The solution is to deactivate, then activate Default_host\SAP\option in SICF.
    This procedure is required once in a while - do you guys know a more permanent solution to this?
    Regards
    Lasse

    Hello Lasse,
    What is the SAP_BASIS version you have?
    Probably you should implement the latest Unified Rendering corrections for your SAP_BASIS release, clear the ICM cache and browser cache and only then test the application.
    I hope this helps.
    Best regards,
    Cristiano

  • IPad Air won't sync music or apps - infinite loop

    I've tried for several days to sync my new iPad air to my music and apps with no success.  All over the USB cable.  I've pared it down to just one album and no apps with no better luck.  Right now it appears to be in an infinite loop where it starts to sync the music, goes to step 5, downloads some music, stops and then restarts the whole process again.  It wipes out the previous few songs loaded when it starts again so it never finishes.  I've tried unchecking all music to sync which wiped out the few songs on the ipad and then tried loading one album.  That worked once out of over 10 times to succusfully load one album.   Subsequent tries have not resulted in any better results, I haven't been able to add any more albums or playlist on top of that only one.  The first time it tries to load after I've wiped the ipad clean there are 4 steps.  On the subsequent tries when it goes into the infinite loop there are 5 steps to syncing the music.  It seems to stop loading at randon song counts and I've tried different albums and playlists.   Right now, I get the following errors.  Yesterday I think it was more of the first error but I can't say for sure.
    The iPad cannot be synced because it cannot be found.
    The iPad cannot be synced. An internal device error occured.
    This is a brand new 32GB model with plenty of free space (since I can't load any of my music).  I have been able to add apps through the app store with no issues.

    I had the same problem. But I was able to fix it with a little luck.
    If you have a backup of your iPad that is functional and has value, hold on to it.
    First, restore/wipe your iPad so it is empty execpt for the stock software.
    Begin to restore your iPad from the backup.
    As it is working, click on the "Manage My Own Music" selection on the iPad sync window. Will ask if you are sure, say yes.
    Un-check and Re-Check the top box in the music section of the sync pages.
    Click Sync at the bottom and let it work.

  • Windows Metro App Terminated by OS

    I'm developing a Windows 8.1 App with Html/JavaScript. The app is for my company and I can't say what it does, but the app is bussiness
    critical. In some scenario our machines can reach 90% of RAM usage and the App is terminated by the OS. I've watched that other Apps are terminated as well, except Microsoft Apps like Skype, Lync etc, they don't get terminated. My question is how can I make
    my app so that the OS can't terminate it?

    @kaloyanlom,
    So the problem is that if other applications use 90% RAM then your Store APP application will be terminated?
    In that way I would recommend you consult your Store App question on the following forum:
    https://social.msdn.microsoft.com/Forums/windowsapps/en-us/home?category=windowsapps
    Visual Studio Setup forum is talking about "Install/Uninstall Visual Studio", it is not the right place for talking about this Store App related question, in my point of view you may need to optimize your code in this kind of scenario.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Stuck in Apple Apps update loop.

    I am a new Mac user. I was updating software (DIgital Camera 4.0) in Apple Apps and received a notice to close Safari before continuing. I closed Safari and my machine s stuck in an update loop. I can't delete the notice from my screen, close Apple Apps nor suht down. Is there a way to stop the update and clear the notice from my screen?

    Mine is doing the same thing and won't charge.  It stays at 2%....this happened suddenly.

  • Imagent.app keeps looping

    Hello,
    imagent.app keeps asking for firewall, allow or deny. but it appears for less then 1 sec and disappears 1 min later same again and same and same and same. i cant catch it. it makes me crazy cant concantrate anything did 3 times of clean installation of OS. added firewall. deleted and waited for request and same issue again. can you help me please ?
    Thanks

    i dont know it makes me crazy. i keep having a trollface mask on my face with fu's.

  • Continuously play an audio file in a java app?(loop)

    NOTE: I AM NOT TALKING ABOUT PLAYING A FILE IN AN APPLET!
    What I need is a way to play the file continuously (or get the file to loop) in a java APPLICATION
    I have found a way to play a file in a java Application : (but i cannot get it to loop)
    Here is what I have so far:
    import sun.audio.*;
    import java.io.*;
    FileInputStream in = new FileInputStream(Filename);
    AudioStream as = new AudioStream(in);
    // Use the static class member "player" from class AudioPlayer to play
    // clip.
    AudioPlayer.player.start(as);
    but How do I make it loop??
    Is there anyway I could possibly use the URL class instead to open the file and the use the AudioClilp class to play that file
    This is something I found on another website that uses this idea, but I dont know how to use it.
    According to the author:
    newAudioClip(URL) is a static method in Applet Class, so it can easily be used in Applications as well.
    e.g.
    AudioClip ac = Applet.newAudioClip(url);
    ac.play(); //play once
    ac.stop(); //stop playing
    ac.loop(); //play continuously
    Here url can refer to some file within the jar file. So, this method is very useful.

    someone16 wrote:
    NOTE: I AM NOT TALKING ABOUT PLAYING A FILE IN AN APPLET!Please don't shout. It's considered rude.
    >
    >
    What I need is a way to play the file continuously (or get the file to loop) in a java APPLICATION
    I have found a way to play a file in a java Application : (but i cannot get it to loop)
    Here is what I have so far:
    import sun.audio.*;
    import java.io.*;
    FileInputStream in = new FileInputStream(Filename);
    AudioStream as = new AudioStream(in);
    // Use the static class member "player" from class AudioPlayer to play
    // clip.
    AudioPlayer.player.start(as);
    but How do I make it loop??Err ... maybe place the code in a loop.
    Is there anyway I could possibly use the URL class instead to open the file and the use the AudioClilp class to play that file
    This is something I found on another website that uses this idea, but I dont know how to use it.
    According to the author:
    newAudioClip(URL) is a static method in Applet Class, so it can easily be used in Applications as well.
    e.g.
    AudioClip ac = Applet.newAudioClip(url);
    ac.play(); //play once
    ac.stop(); //stop playing
    ac.loop(); //play continuously
    Here url can refer to some file within the jar file. So, this method is very useful.So you can use a URL.

  • Random apps terminating

    Since my iOS 7.03 upgrade have I experienced several random apps just dying on me.
    I would be in the middle of Linkedin, Whatsapp, Twitter or Facebook when the application dies.
    My iOS 7.03 is seriously sick.
    Can someone please advise me what to do?
    Thx,
    Jack

    Are they apps that you've bought/downloaded on another device and do you have automatic downloads turned 'on' on the iPad ?

  • Using Mac Pro, finder just INSTANTLY restarts, all open apps terminated.

    I have experienced this problem twice now, which is twice too many times! While using my MacPro, after having just upgraded to Snow Leopard, the computer quits everything and in an instant, the finder reboots. Anything that was open seems to be gone. This is bad news bears. Any suggestions?

    MacFixit:
    Finder crashes when folder containing certain JPEG images is opened
    http://reviews.cnet.com/8301-13727_7-10347728-263.html
    ... and of course run Disk Warrior (4.2, SL version) from another drive running 10.5.8 or SL. (keep a small system for repairs only somewhere you can rely on to be able to boot from)

  • Calendar is in terminal loop with "Moving Calendars to server account"...

    ...barber pole. This has been going on for almost 8 hours! I've tried force quiting but it still comes up in this mode. Help!

    I have this issue too.

  • Computer startup leads into Terminal

    Hello,
    Last night, after a restart, my tower booted up and went straight into the Terminal, the one that takes up the whole screen. In other words I was not able to immediately login and go to my desktop, the computer went straight to the terminal.
    After entering the WRONG login name and password n the terminal (it was an accident) I was sent to the regular login screen and was able to login to my desktop. I reset the machine again and was sent to the terminal again. I entered the correct login and password and it waited for a command. I typed exit and it took me to the regular login page. I did another restart and it sent me to the terminal for a third time.
    At this time I ran a fsck -f to repair permissions. It didn't find anything that needed fixing but it let me exit to the regular login page. I did another restart and was back in the terminal. I ran an app called Cocktail that cleared a lot of caches. I did another restart and this time was not sent to the terminal, but to the regular login page.
    The only thing I did out of the ordinary before all of this mess started was run a prebinding command in the Terminal Utlility. I did this because FCP has not been launching and a forum post suggested it.
    Does anyone have any other suggestions as to why I was stuck in the Terminal loop?
    Thanks for your help!

    It's not the Terminal. It's either the single-user or verbose mode. Basically, it was booting into the command line interface. Search these forums for single-user or Darwin and peruse the results. Since Cocktail appears to have fixed the problem, I wouldn't worry about it. However, you might want to check out these maintenance tips:
    Macintosh OS X Routine Maintenance
    Mac OS X 10.3/10.4: System maintenance
    Mac OS X speed FAQ
    Maintaining OS X

  • Delete app from iPad with iTunes is Fine, but in local App Store they are still present. how to delete this footprints?

    Delete AppStore via iTunes Works Fine, but the footprints are still visible. In the iPad Local app Store Looping at tab 'Not on iPad'. How can these footprints are Delegat too, so they aren' synchronised any more?

    Click on the app and press delete.

Maybe you are looking for