Help, make the program start over

Hi!
I want to make this program to start over, an something is wrong, but I can not figure it out, this is new to me. the program is in swedish, but I will try to explaine the functions.
If you type in zero (0) the program will halt and ask for a value greater then zero. However when you type in a greater value, it will never do the actual calculation. If you from the begining type in a greater value it will do the math. Can anyone help me to correct this.
Plattform: mac and eclipse, with latest updates.
Java code:
import static javax.swing.JOptionPane.*;
public class sf?r {
     public static void main (String[] arg) {
     String indata;
     indata = showInputDialog (null, "Ange radien i sf?ren du vill r?kna ut Volymen och Arean");
     double radien = Double.parseDouble (indata);
int three = 3;
int four = 4;
double pi = 3.14;
double volym = four*pi*radien*radien*radien/three;
double area = four*pi*radien*radien;
while (radien <=0) {
     indata = showInputDialog (null, "Felaktigt v?rde, Ange ett v?rde st?rre ?n 0");
     radien = Double.parseDouble (indata);
showMessageDialog (null, "Volymen ?r " + volym + " Arean ?r " + area);
System.exit (0);
Martin

   while (radien <=0) {
     indata = showInputDialog (null, "Felaktigt v?rde, Ange ett v?rde st?rre ?n 0");
     radien = Double.parseDouble (indata);
} this test for 0 is after you do the calculations:
  double volym = four*pi*radien*radien*radien/three;
double area = four*pi*radien*radien; you need to test for 0 before the calculations.
just FYI, when posting code, there are "CODE" tags (look at the top of the posting window). It'll make the code much easier to read
Edited by: redfalconf35 on Nov 21, 2007 9:18 AM

Similar Messages

  • How do you make the program start?

    I have installed PSE 11 twice, now; the second time after an uninstallation of the first installation.  Both times, the program started immediately FROM the installation.  After exiting from the program, I have not been able to restart the program.  I click on it; I double click on it (which should start 2 copies of the program!); I right click and click Open; I right click and click "open as administrator".  Absolutely NOTHING happens.  Is there some sort of glitch that means you have to leave the program open permanently?  Please, how do I open the program? 
    Thank you.
    Cherie Brumfield

    Thanks so much for responding.  As it happens, I had already tried that
    approach, with no results.  I also spent some time last evening with a tech
    on the Adobe Chat page, also with no results.  So I just reloaded my PSE 8
    program, which does still work!  And this morning I get a notice of an
    Adobe update to PSE 11 and, guess what?!--NOW PSE 11 works just fine!!  Go
    figure!
    All of which has nothing to do with you having responded to my plea for
    help.  I really appreciate someone responding; it's nice to know that
    people "out there" really do care.  Thank you.
    Cherie
    On Wed, Feb 6, 2013 at 4:55 AM, bridge_mastero

  • How do you make the program repeat itself?

    How would I make it so that when the if statement at the end of the code the program starts over from the begining?
    Any help appreciated. Here is the code if you wanna see it.
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    class SuperTester{
         public static void main ( String[] args ){
         // Create array that will hold deck
         Deck[] decko = new Deck[52];     
         // Fill the array with a deck
         decko = Deck.makeDeck();
         // Print new deck
         System.out.println( "PRINT NEW DECK" );
         System.out.println( "" );
         Deck.printDeck( decko );
         // Shuffle the deck ( simulated riffle shuffling )!
         decko = Deck.shuffleDeck( decko );
         // Print the shuffled deck
         System.out.println( "" );
         System.out.println( "PRINT SHUFFLED DECK" );
         System.out.println( "" );
         Deck.printDeck( decko );
         // Print first 5
         System.out.println( "" );
         System.out.println( "PRINT TOP 5" );
         System.out.println( "" );
         Deck.printFirstFive( decko );
         // Print single card
         System.out.println( "" );
         System.out.println( "PRINT SINGLE CARD" );
         System.out.println( "" );
         Deck.printCard ( decko [2] );
         System.out.println( "" );     
         BufferedReader in = new BufferedReader( new InputStreamReader (System.in));
         int input;
         System.out.println( " Do you want to re-run program? " );
         System.out.println( " Push 1 for yes " );
         System.out.println( " Push 2 for no " );
         System.out.println( "" );
    try
         input = Integer.parseInt( in.readLine() );
    catch( Exception e ){
    if ( input == 1 ){
    //WHAT DO I PUT HERE TO MAKE THE PROGRAM REPEAT ITSELF?
         } // end method
    } // end class

    So i should just do something like?
    int x = 0;
    while (x == 0){
    //code
    if (inpu == 1) {
        x == 0;
    }else{ x == 1; }                                                                                                                                                                                                                                                       

  • Why do i have to keep clicking my left mouse button to make the program work it just stops and if left click it starts working

    Why do i have to keep clicking my left mouse button to make the program work it just stops and if left click it starts working. I'v only just started to use this program and It's no good at all if I go to a website and click a button I have to keep clicking it to finish what its doing.

    hello jeffsprig, can you try to replicate this behaviour when you launch firefox in safe mode once?
    [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    multiple other affected users have reported that this was an issue caused by malware on their pc. please run a scan of your system with [http://www.bleepingcomputer.com/download/adwcleaner/ adwcleaner] and the [http://www.malwarebytes.org/products/malwarebytes_free free version of malwarebytes].
    [[Troubleshoot Firefox issues caused by malware]]

  • How do I Initialize a button to be enabled when the program start and if pressed then disable and gray it until a certain action is taken then comeback to the enabled state?

    Hi!!!
    I'm doing a program with the following buttons: Run, Abort, Repeat and Exit. When the program starts from the first time only Run and Exit button will be enabled and not disabled so the user doesn't press the Abort and Repeat button. The user has to select from a menu bar the test he wants to make then if he presses the Run button a pop up window will come up asking for the serial number and his name, and will comeback to the main program with the entered information. The user now has to press the Run button again to start the test, when the test starts the Abort button now will be enable
    d and not disabled, when the test ends the Repeat button will be enabled and disabled. If the user selects new test from the menu bar the whole process will come again. I'm having problems with the menu bar because it has a time-out and when that occurs the program gets crazy. Also I'm not sure about what mechanical action I have to use for the Run. Do I need to count the times the Run button is press so the 2nd time is pressed it will be disabled. Do I need to use a sequential and where I initialize the buttons so the first time they are like I want (Inside or OUtside the while loop that ends with the Exit button) Any help wil be appreciated.

    I'm not sure about the menu bar because i've never used them..i tend to go for listboxes instead.
    As for the buttons, if you want to wire the button to a local variable then the button must be a switch, otherwise a latch is ok. But remember you will probably need to reset the button at the end of a run (ie. wire a constant through the while loop to the local variable for the switch). To initialize the buttons at the start, wire constants to their locals outside the main execution while loop.
    Put the disabling/enabling functions in the parts of the program the button has activated. For example, you say the 2nd time the Run button is pressed you run the 'test', enable the Abort button and want to disable the Run button - put these property nodes into th
    e 'test' sequence/loop.
    Sequences are useful to control when you want buttons to be modified. I use them if i cant sequence the order of execution any other way. But try and avoid using multiple frames as it can get confusing if you start hiding code.
    If you are still having problems, post an example of your program in no higher than LV 6.0.2 and i will try and adapt it for you.
    Kim

  • I have registered Adobe CS, and every two/three weeks i get a message that I am using a trial version.  I provide my registration key, and the fun starts over in two/three weeks.  What is going on?

    I have registered Adobe CS, and every two/three weeks i get a message that I am using a trial version.  I provide my registration key, and the fun starts over in two/three weeks.  What is going on?

    I'm not sure what's happening. See if you can get some help from Web Chat here:
    Serial number and activation support

  • How to use the created search helps in the program?

    Hi Everyone,
    I know how to create Search help elementary / collective search help through SE 11. I have a question, how can I make use of the created search help in the program.
    How to use the Search help in the programs, which is created through SE11
    Subbu.

    Hi,
    In case if you want to use in parameters statement, then we can use the suffix MATCHCODE OBJECT syntax.
    Eg.
    report abc.
    parameters : a(10) type c matchcode object ZBELNR.
    Hope this helps.
    regards,
    amit m.

  • During/after upgrading to ios8.1 my ipad air is looping is a screen where i see the apple logo after a minute or so i see a flash of bleu then black en the it starts over again....i can't even turn of.

    During/after upgrading to ios8.1 my ipad air is looping is a screen where i see the apple logo after a minute or so i see a flash of bleu then black en the it starts over again....i can't even turn of. Help?

    Hi,
    Had the same issue.  Hard reset not working.
    What I did was: start your mac/pc and open iTunes, hold down the home button of the iPad (and while holding the button), connect it to the PC with the cable.
    Keep pressing until you get a pop-up asking to upgrade or restore.
    Hope this helps for you!
    Xavier

  • How do i make the program hold after it has created a JFrame

    I have created a JFrame with which the user shall login to a server. I call this JFrame from my main method (the JFrame-class is in a separate file). My problem is that after the login-window is created and set visible, my main method continues, i would like it to wait until the user have logged in before running the rest of the code.
    this i my main method:
    new LoginWindow();
    System.out.println("Logged in: "+Session.isLoggedin()+
                    "\nUsername: "+Session.getUsername());Session.isLoggedin() returns a boolean, true if user is logged in and otherwise false. class LoginWindow extends JFrame.
    i have tried to use a while-loop to solve my problem:
    while(!Session.isLoggedin()) { }and also
    whiel(true){
        if(Session.isLoggedin())
            break;
    }these while-loops never breaks, i have waited for about 3 min after successful login.It isn't because Session.isLoggedin() returns false, it does return true after a successful login (i've checked).
    the funny thing however is if i print something in the while-loop i does break when login is finished
    example:
    whiel(true){
        System.out.println(Session.isLoggedin());
        if(Session.isLoggedin())
            break;
    }this code makes the program wait until the login-phase is complete but i don't want it to print "text" a few thousand times while the user is logging in. (i've used "hej" as output aswell)
    Since i have no idea how long it will take for a user to log in i can't use the System.sleep(value) method.
    I would really appreciate any help
    Thanks in advance
    //Oscar

    SnuShogge wrote:
    I am still curious about why the while-loop only breaks if i print something using System.out.println(""), i didn't think that would make a difference since the break-statement remains the same.In general you should avoid trying to use while (true) or its variants in a Swing GUI as it often messes with the EDT, the main thread that renders the GUI graphics and interacts with the user.
    My problem i however partially solved by using a JDialog instead of a JFrame. I am planning on using JFrame later in the program so the problem might come back to haunt me if it isn't solved.This may not be a great idea. Usually an application has one single JFrame. Most other distinct windows a dialogs of one sort or another and should be JDialogs, not JFrames. Often better still is to use a CardLayout to swap JPanels or other components.

  • Need a script to make the browser fly over the screen, bouncing around

    I have heard about the youareanidiot.org virus. I need a script to make the browser fly over the screen, bouncing around. Do you have one?

    This is a professional forum, we do not help with jokes that will cost you your job.
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • Make the program run again, given the user's input?

    Hello,
    I need a little help with this program, you can see the entire thing below. I'm trying to make the program give the user the option to run again, using y or n. It's for a college project. Thanks.
    import java.util.*;
    class MyFifthProgram
         public static void main (String[] args)
              //char letterOnTelephone;
              do
                   System.out.print("Enter a letter from A - Z and I will output the corresponding number \non the telephone, then press enter:");
                   Scanner keyboard = new Scanner(System.in);
                   String letterOnTelephone = keyboard.next();
                   char letter = letterOnTelephone.charAt(0);
                   switch (letter)
                        case 'Q':
                        case 'q':
                        case 'Z':
                        case 'z':
                             System.out.println("Sorry, the letter " + letterOnTelephone + " cannot be found on the telephone....");
                             break;
                        default:
                             System.out.println("Sorry, the key " + letterOnTelephone + " cannot be found on the telephone......");
                             break;     
                        case 'A':
                        case 'a':
                        case 'B':
                        case 'b':
                        case 'C':
                        case 'c':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 2.");
                             break;
                        case 'D':
                        case 'd':
                        case 'E':
                        case 'e':
                        case 'F':
                        case 'f':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 3.");
                             break;
                        case 'G':
                        case 'g':
                        case 'H':
                        case 'h':
                        case 'I':
                        case 'i':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 4.");
                             break;
                        case 'J':
                        case 'j':
                        case 'K':
                        case 'k':
                        case 'L':
                        case 'l':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 5.");
                             break;
                        case 'M':
                        case 'm':
                        case 'N':
                        case 'n':
                        case 'O':
                        case 'o':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 6.");
                             break;
                        case 'P':
                        case 'p':
                        case 'R':
                        case 'r':
                        case 'S':
                        case 's':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 7.");
                             break;
                        case 'T':
                        case 't':
                        case 'U':
                        case 'u':
                        case 'V':
                        case 'v':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 8.");
                             break;
                        case 'W':
                        case 'w':
                        case 'X':
                        case 'x':
                        case 'Y':
                        case 'y':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 9.");
                             break;                                             
                   System.out.println("Would you like to run this program again? Enter Y for yes, or N for no:");
                   Scanner keyboard1 = new Scanner(System.in);
                   String runAgain = keyboard1.next();
                   char runIt = runAgain.charAt(0);
                   }while (runIt == 'y');
                        System.out.println("You can choosen " + runAgain + " therefor the program will run again.");
         }

    Thanks! That did the trick, however that doesn't solve my problem. How do I ask the user to run the program again at the end of the program? What am I missing?
    // Program takes a single letter and displays the corresponding digit on the telephone.
    import java.util.*;
    class MyFifthProgram
         public static void main (String[] args)
              System.out.println("Would you like to run this program? Enter Y for yes, or N for no:");
              Scanner keyboard1 = new Scanner(System.in);
              String runAgain = keyboard1.next();
              char runIt = runAgain.charAt(0);
              if (runIt == 'n')
                   System.exit(0);
              else if (runIt == 'N')
                   System.exit(0);
              do
                   System.out.print("Enter a letter from A - Z and I will output the corresponding number \non the telephone, then press enter:");
                   Scanner keyboard = new Scanner(System.in);
                   String letterOnTelephone = keyboard.next();
                   char letter = letterOnTelephone.charAt(0);
                   switch (letter)
                        case 'Q':
                        case 'q':
                        case 'Z':
                        case 'z':
                             System.out.println("Sorry, the letter " + letterOnTelephone + " cannot be found on the telephone....");
                             break;
                        default:
                             System.out.println("Sorry, the key " + letterOnTelephone + " cannot be found on the telephone......");
                             break;     
                        case 'A':
                        case 'a':
                        case 'B':
                        case 'b':
                        case 'C':
                        case 'c':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 2.");
                             break;
                        case 'D':
                        case 'd':
                        case 'E':
                        case 'e':
                        case 'F':
                        case 'f':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 3.");
                             break;
                        case 'G':
                        case 'g':
                        case 'H':
                        case 'h':
                        case 'I':
                        case 'i':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 4.");
                             break;
                        case 'J':
                        case 'j':
                        case 'K':
                        case 'k':
                        case 'L':
                        case 'l':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 5.");
                             break;
                        case 'M':
                        case 'm':
                        case 'N':
                        case 'n':
                        case 'O':
                        case 'o':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 6.");
                             break;
                        case 'P':
                        case 'p':
                        case 'R':
                        case 'r':
                        case 'S':
                        case 's':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 7.");
                             break;
                        case 'T':
                        case 't':
                        case 'U':
                        case 'u':
                        case 'V':
                        case 'v':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 8.");
                             break;
                        case 'W':
                        case 'w':
                        case 'X':
                        case 'x':
                        case 'Y':
                        case 'y':
                             System.out.println("The letter " + letterOnTelephone + " corresponds to the number 9.");
                             break;                                             
                   }while (runIt == 'n');
              //          System.out.println("Would you like to run this program? Enter Y for yes, or N for no:");
              //          Scanner keyboard2 = new Scanner(System.in);
              //          String runAgain1 = keyboard2.next();
              //          char runIt1 = runAgain1.charAt(0);
              //          if (runIt1 == 'n')
              //               System.exit(0);
              //          else if (runIt1 == 'N');
              //               System.exit(0);
         }

  • How do I make a program start up right when I turn my computer on?

    Hello all!
    Just wondering how I can make the program "iPulse" start right up when I turn my awesome computer on everyday!
    Thank you

    Add it to the list of login items for your account in the Accounts pane of System Preferences, or control-click/click and hold its Dock icon and set it to open at login.
    (34979)

  • HT3964 My MacBook Pro will not boot up. The screen remains dark although the the comput makes the characteristic start up sound. The sleep light is showing.

    MY MacBook Pro will not boot upThe screen is dark, but the sleep light is on and it makes the characteristic start up sound.What is wrong?

    There is always the forum for MBP
    MacBook Pro
    https://discussions.apple.com/community/notebooks/macbook_pro
    https://discussions.apple.com/community/mac_os?view=discussions 
    http://www.apple.com/support/macbookpro

  • I have a problem with elements 8. When ever I start a new project, the program searches for the old, latest used filmmaterial, I have used before. That means, if I use a different DVD, it take so much time, until the program starts. So how can I stopp the

    I have a problem with elements 8. When ever I start a new project, the program searches for the old, latest used filmmaterial, I have used before. That means, if I use a different DVD, it take so much time, until the program starts. So how can I stopp the automatically uploading of old material?
    Thanks

    You have 2 unreachable statements in this method.
    public static int eval(String s2, String op, String s3) {
    return lookup(s2);
    return lookup(op);
    return lookup(s3);
    } You're missing a } at the end of this method:
    public static int lookup(String s) {
        for(int k = 0; k < symbols.length; k++){
            String symbol = symbols[k];
            if(s.equals(symbol))
                return k;
        }You have some loose } and ; at the end of the file:
    public static void main(String args[])
    commandline();
    }

  • Are there any packages compatable with LabVIEW to make the program CFR21 part 11

    Hello All,
    Are there any packages that are compatable with a LabVIEW program, which creates a .csv file, that would make the program CFR 21 Part 11 compliant?

    A quick search of Google for " cfr 21part 11 labview" returns several links.
    http://www.ni.com/white-paper/4570/en
    http://www.ni.com/white-paper/8751/en
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

Maybe you are looking for

  • Condition records for Material

    Hi, We have made a systems like  Package material  means  We have one material with item category ZBOM  which is the main material and for this material we have made BOM with different line items  when we enter package material in VA01  system automa

  • SAP FSCM ( CFM) TAPO error

    Hi All We hv done configuration for a new CR in Traded Average Price Option (TAPO) and when testing the same we got the below error. I hv checked all the configurations done in product type, transaction type, flow type and update types and itu2019s a

  • T410s - screen makes clunk noise at bottom right support

    Hi When I close the screen of my T410s there is a loud audible clunk sound from the bottom right support bracket. It seems like the screen is a little loose at the bottom right support as there is "give" or movement at that joint. Has anyone come acr

  • Spry accordion has extra phantom tabs

    In this template, I added extra  tabs to the left hand navigation by just copying and pasting the code  for the original tabs. Then I noticed there were extra  tabs in the accordion also, which don't work. Looking at  the code, I see that the navigat

  • MIDP 2.0: Problems on real device

    Hi All, im experiencing an issue with my small midlet. I wrote it using NBeans5Beta and tested on WTK 2.3 and it worked fine- without any exceptions beeing thrown etc. But on real device I have - Moto V600 (MIDP 2.0, CLDC 1.0) it crashes in some stra