Need help fixing my code...

I'm currently working on a problem for school where you have to make a game called Pig.
I worked on it but need help on fixing it because it won't work the way I want it to, and I'm not sure what the problem is.
public class Pig
    public static void main (String[] args)
      int num1, num2, num3 = 0, num4, num5, num6 =0;
      String answer="y";
      PairOfDice die1 = new PairOfDice(); // die # 1
      PairOfDice die2 = new PairOfDice(); // die # 2
      while (num3 <= 100 || num6 <= 100)
      // rolls dice
      while (answer.equalsIgnoreCase("y"))
          num1 = die1.roll();
          num2 = die2.roll();
          if (num1 == 1 || num2 == 1) // when either face is 1
            {num3 = num3;
             answer = "n";}
          else  
            if (num1 == 1 && num2 == 1) // when both faces are 1
                {num3 = 0;
                 answer = "n";}
            else
                num3 += num1 + num2; // sum of two faces
      System.out.println (num1 +" "+ num2); // shows both faces
      System.out.println (num3); // shows the sum of faces
      System.out.println ("Do you want to roll again? (y/n)");
      answer = Keyboard.readString();
      if (answer.equalsIgnoreCase("n"))
        answer = "1";
      while (answer.equalsIgnoreCase("1"))
          while (num6 <= 20)
             num4 = die1.roll();
             num5 = die2.roll();
             if (num4 == 1 || num5 == 1) // when either face is 1
                 {num6 = num6;
                  answer = "2";}
             else  
                if (num4 == 1 && num5 == 1) // when both faces are 1
                    {num6 = 0;
                     answer = "2";}
                else
                    num6 += num4 + num5; // sum of two faces
          System.out.println (num4 +" "+ num5); // shows both faces
          System.out.println (num6); // shows the sum of faces
          answer = "y";
      Here is my code. It runs okay, but when the dice rolls a 1, it doesn't jump to the next while loop. I need the program to go to the "while loop answer = 1" when the dice rolls a 1 from the "while loop answer = y". If you see my code, I did it by making the answer = "n" to make it jump to the next while loop. I'm sorry if my explanation is confusing. It's my first time asking for help here...
You don't have to fix the code for me, as long as you tell me what I'm doing wrong.
Please help me...Thank you for your help.
Edited by: nakatsu on Nov 12, 2007 7:03 PM

Hint: all your code does NOT have to be in one method. You have numerous loops some nested inside others. This is starting to get mighty messy and can be tidied up if you think about how you can break some of the code down into smaller chunks and place these into their own methods.
while (answer.equalsIgnoreCase("1"))What other case is there?

Similar Messages

  • I need help fixing this... i can't get PDF to open

    [2011-08-07:20:00:49] Launching subprocess with commandline c:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater -installupdatecheck
    [2011-08-07:20:00:49] Runtime Installer end with exit code 0
    [2011-08-07:20:00:49] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-07:20:00:49] Commandline is: -installupdatecheck
    [2011-08-07:20:00:49] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-07:20:00:49] Performing pingback request
    [2011-08-07:20:00:50] Pingback request completed with HTTP status 200
    [2011-08-07:20:00:50] Starting runtime background update check
    [2011-08-07:20:00:50] Begin Background update download from http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update
    [2011-08-07:20:00:50] Unpackaging http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update to C:\Users\Troy M\AppData\Roaming\Adobe\AIR\Updater\Background
    [2011-08-07:20:00:50] Runtime update not available
    [2011-08-07:20:00:50] Unpackaging cancelled
    [2011-08-07:20:00:50] Runtime Installer end with exit code 0
    [2011-08-07:20:01:23] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-07:20:01:23] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_010122AM.pdf"
    [2011-08-07:20:01:23] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-07:20:01:24] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_010122AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla54C3.tmp
    [2011-08-07:20:01:24] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-07:20:01:29] Application Installer end with exit code 7
    [2011-08-07:20:01:33] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-07:20:01:33] Commandline is: -arp:uninstall
    [2011-08-07:20:01:33] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-07:20:01:37] Relaunching with elevation
    [2011-08-07:20:01:37] Launching subprocess with commandline c:\program files (x86)\common files\adobe air\versions\1.0\resources\adobe air updater.exe -eu
    [2011-08-07:20:01:37] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-07:20:01:37] Commandline is: -stdio \\.\pipe\AIR_2996_0 -eu
    [2011-08-07:20:01:37] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-07:20:01:37] Starting runtime uninstall. Uninstalling runtime version 2.7.0.19530
    [2011-08-07:20:01:37] Uninstalling product with GUID {FDB3B167-F4FA-461D-976F-286304A57B2A}
    [2011-08-07:20:01:39] Runtime Installer end with exit code 0
    [2011-08-07:20:01:39] Elevated install completed
    [2011-08-07:20:01:39] Runtime Installer end with exit code 0
    [2011-08-08:05:12:23] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:05:12:23] Commandline is: -silent
    [2011-08-08:05:12:23] No installed runtime detected
    [2011-08-08:05:12:23] Starting silent runtime install. Installing runtime version 2.7.0.19530
    [2011-08-08:05:12:24] Installing msi at c:\users\troym~1\appdata\local\temp\airb8a4.tmp\setup.msi with guid {FDB3B167-F4FA-461D-976F-286304A57B2A}
    [2011-08-08:05:12:43] Runtime Installer end with exit code 0
    [2011-08-08:05:14:53] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:05:14:53] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_101451AM.pdf"
    [2011-08-08:05:14:53] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:05:14:54] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_101451AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla1120.tmp
    [2011-08-08:05:14:54] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:05:15:01] Application Installer end with exit code 7
    [2011-08-08:05:16:11] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:05:16:11] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_101610AM.pdf"
    [2011-08-08:05:16:11] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:05:16:11] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_101610AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla3F41.tmp
    [2011-08-08:05:16:11] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:05:16:16] Application Installer end with exit code 7
    [2011-08-08:06:29:43] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:29:43] Commandline is: "C:\Users\Troy M\Documents\hs_11jul.pdf"
    [2011-08-08:06:29:43] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:29:44] Unpackaging file:///C:/Users/Troy%20M/Documents/hs_11jul.pdf to C:\Users\Troy M\AppData\Local\Temp\fla13FC.tmp
    [2011-08-08:06:29:45] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:29:46] Application Installer end with exit code 7
    [2011-08-08:06:30:25] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:30:25] Commandline is:
    [2011-08-08:06:30:25] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:30:28] Launching subprocess with commandline c:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater -installupdatecheck
    [2011-08-08:06:30:28] Runtime Installer end with exit code 0
    [2011-08-08:06:30:29] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:30:29] Commandline is: -installupdatecheck
    [2011-08-08:06:30:29] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:30:29] Performing pingback request
    [2011-08-08:06:30:29] Pingback request completed with HTTP status 200
    [2011-08-08:06:30:29] Starting runtime background update check
    [2011-08-08:06:30:29] Begin Background update download from http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update
    [2011-08-08:06:30:29] Unpackaging http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update to C:\Users\Troy M\AppData\Roaming\Adobe\AIR\Updater\Background
    [2011-08-08:06:30:30] Runtime update not available
    [2011-08-08:06:30:30] Unpackaging cancelled
    [2011-08-08:06:30:30] Runtime Installer end with exit code 0
    [2011-08-08:06:31:02] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:31:02] Commandline is: "C:\Users\Troy M\Documents\hs_11jul.pdf"
    [2011-08-08:06:31:02] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:31:02] Unpackaging file:///C:/Users/Troy%20M/Documents/hs_11jul.pdf to C:\Users\Troy M\AppData\Local\Temp\fla43F2.tmp
    [2011-08-08:06:31:02] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:31:05] Application Installer end with exit code 7
    [2011-08-08:06:31:08] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:31:08] Commandline is: "C:\Users\Troy M\Documents\hs_11jul.pdf"
    [2011-08-08:06:31:08] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:31:08] Unpackaging file:///C:/Users/Troy%20M/Documents/hs_11jul.pdf to C:\Users\Troy M\AppData\Local\Temp\fla5C13.tmp
    [2011-08-08:06:31:08] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:31:10] Application Installer end with exit code 7
    [2011-08-08:06:31:25] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:31:25] Commandline is: -arp:uninstall
    [2011-08-08:06:31:25] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:31:27] Runtime Installer end with exit code 6
    [2011-08-08:06:32:54] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:32:54] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_113253AM.pdf"
    [2011-08-08:06:32:54] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:32:55] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_113253AM.pdf to C:\Users\Troy M\AppData\Local\Temp\flaFB7D.tmp
    [2011-08-08:06:32:55] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:34:32] Application Installer end with exit code 7
    [2011-08-08:06:36:06] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:36:06] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_113606AM.pdf"
    [2011-08-08:06:36:06] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:36:06] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_113606AM.pdf to C:\Users\Troy M\AppData\Local\Temp\flaE83C.tmp
    [2011-08-08:06:36:06] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:36:08] Application Installer end with exit code 7
    [2011-08-08:06:40:11] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:40:11] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_114010AM.pdf"
    [2011-08-08:06:40:11] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:40:11] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_114010AM.pdf to C:\Users\Troy M\AppData\Local\Temp\flaA488.tmp
    [2011-08-08:06:40:11] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:40:17] Application Installer end with exit code 7
    [2011-08-08:06:41:40] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:41:40] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_114140AM.pdf"
    [2011-08-08:06:41:40] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:41:40] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_114140AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla138.tmp
    [2011-08-08:06:41:41] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:42:57] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
    [2011-08-08:06:42:57] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_114257AM.pdf"
    [2011-08-08:06:42:57] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-08-08:06:42:57] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_114257AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla2E11.tmp
    [2011-08-08:06:42:58] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
    [2011-08-08:06:43:02] Application Installer end with exit code 7
    [2011-08-08:06:44:48] Application Installer end with exit code 7

    i have reader... and this is the error message i get when i attempt to open one
    sorry, an error has occured.
    The application could not be installed because the installer file is damaged.  Try obtaining a new installer file from the application author.
    Date: Mon, 8 Aug 2011 11:19:37 -0600
    From: [email protected]
    To: [email protected]
    Subject: I need help fixing this... i can't get PDF to open
    To open files with the .pdf extension, please use http://get.adobe.com/reader/.
    Thanks,
    Chris
    >

  • Uloading ebook using iProducer rec'd error: ERROR ITMS-9000: "Unable to parse nav file: toc.ncx" at Book. I don't understand and need help fixing it. Please Help

    Uloading ebook using iProducer rec'd error: ERROR ITMS-9000: "Unable to parse nav file: toc.ncx" at Book. I don't understand and need help fixing it. Please Help if you've the knowledge.
    Many Thanks

    Yep, i just did it again. The entire scroll-bar widget, complete with formatted text, graphics, etc., pasted itself nicely in another book. Two different files, the same widget.
    I use the scroll-bar widgets for most of my texts. (I have audio buttons on the side, and the scripts are within the widget, to the side). My only text is within widgets, and text boxes, naturally. 
    I am following your recommendation: cleaning files, etc. I am remaking the book anew. I need to convince the EPUB bot or whatever that my file looks and works nicely on all my devices. You would expect an error message when previewing the book: 'Hey Amigo, your file is flawed, stop working on it, and get back to the drawing board." Should be able to try again next Monday.

  • Need help in transcation code ime0

    I need help in transaction code ime0. I mean to say what is this TCode doing? What different Drill-down program means? Where I can use this report?
    Regards,
    Subhasish

    Hi
    Please check the link for help
    <a href="http://help.sap.com/saphelp_47x200/helpdata/EN/5c/8db33f555411d189660000e829fbbd/frameset.htm">CA - Drilldown Reporting</a>
    Hope it helps
    Anirban

  • I deleted aperture and now my sistem is acting crazy. I desperately need help fixing it.Can anyone help me please?

    I deleted aperture and now my sistem is acting crazy.The dock disappeared and almost all icons are gone except for their names.I have an important project for tomorrow and I desperately need help fixing it.Can anyone help me please?

    Well it all started with Aperture 3 trying to import some photos from my iphone.It took ages to import those photos and like I was in a hurry to finish my work in Illustrator so I tryied to force quit on A3 and it didn´t, so I shut down the computer and started over.it was all ok but I uninstalled the A3 and the I realized the icons were back to original form and a few fonts changed.so I Installed the trial version of A3.I did a restart of the system and then there was.aperture lauching but no dock and a 80% of the icons disappeared, but the names of the files and folder remained.and I cand acces the apps from the apple sign on the left corner.I tried also restarting a few time but it´s always the same.I am a recent user of a mac , and please excuse my bad english.If this is in any way useful please help me!

  • I did a manual restore but it gave me an error it was 3914 i need help fixing it.

    i did a manual restore but it gave me an error it was 3914 i need help fixing it.

    From this Apple support document: iTunes: Specific update-and-restore error messages and advanced troubleshooting
    This device is not eligible for the requested build: Also sometimes displayed as an "error 3194." If you receive this alert, update to the latest version of iTunes. Third-party security software or router security settings can also cause this issue. To resolve this, follow Troubleshooting security software issues.
    Downgrading to a previous version of iOS is not supported. If you have installed software to perform unauthorized modifications to your iOS device, that software may have redirected connections to the update server (gs.apple.com) within the Hosts file. First you must uninstall the unauthorized modification software from the computer, then edit out the "gs.apple.com" redirect from the hosts file, and then restart the computer for the host file changes to take affect.  For steps to edit the Hosts file and allow iTunes to communicate with the update server, see iTunes: Troubleshooting iTunes Store on your computer, iPhone, iPad, or iPod—follow steps under the headingBlocked by configuration (Mac OS X / Windows) > Rebuild network information > The hosts file may also be blocking the iTunes Store. If you do not uninstall the unauthorized modification software prior to editing the hosts file, that software may automatically modify the hosts file again on restart. Also, using an older or modified .ipsw file can cause this issue. Try moving the current .ipsw file, or try restoring in a new user to ensure that iTunes downloads a new .ipsw.
    Error 3194: Resolve error 3194 by updating to the latest version of iTunes. "This device is not eligible for the requested build" in the updater logs confirms this is the root of the issue. For more Error 3194 steps see: This device is not eligible for the requested build above.
    B-rock

  • I need help with my shockwave flash it is crashed i need help fixing

    I need help with shockwave flash it is crash i need help fixing it

    http://forums.adobe.com/thread/1195540

  • I need help with this code error "unreachable statement"

    the error_
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errors
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class Tools//tool class
    private int numberOfToolItems;
    private ToolItems[] toolArray = new ToolItems[10];
    public Tools()//array of tool
    numberOfToolItems = 0;
    for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
    toolArray[i] = new ToolItems();
    }//end for loop
    }//end of array of tools
    public int search(int id)//search mehtod
    int index = 0;
    while (index < numberOfToolItems)//while and if loop search
    if(toolArray[index].getID() == id)
    return index;
    else
    index ++;
    }//en while and if loop
    return -1;
    }//end search method
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0;
    int index;
    index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    }//end delete method
    public void display()//display method
    for(int i = 0; i < numberOfToolItems; i++)
    //toolArray.display(g,y,x);
    }//end display method
    public String getRecord(int i)//get record method
    // return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
    }//end getrecod
    }//end class
    Edited by: ladsoftware on Oct 9, 2009 6:08 AM
    Edited by: ladsoftware on Oct 9, 2009 6:09 AM
    Edited by: ladsoftware on Oct 9, 2009 6:10 AM
    Edited by: ladsoftware on Oct 9, 2009 6:11 AM

    ladsoftware wrote:
    Subject: Re: I need help with this code error "unreachable statement"
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errorsThe compiler is telling you exactly what the problems are:
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
    int index;
    index = search(id);  //< -----------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    // <<== HERE where is the return statement?
    }//end delete method
    public String getRecord(int i)//get record method
    // return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
    }//end getrecod
    }//end class

  • I need help fixing kernel panic asap please help

    i need help fixing kernel panic asap please help

    OS X- About kernel panics
    Mac OS X- How to log a kernel panic
    Post a copy of your most recent complete panic log.

  • I need help fixing itunes crashes on my old mac

    i need help fixing itunes crashes on my old mac

    Thanks for your reply,
    I have both the silver discs specific to my iMac and Mac Pro models that you receive with your Mac, and a general copy of Snow Leopard that you buy from the store.
    I used the silver disc that is specific for my iMac to install the drivers, and Boot Camp 3.0 on my iMac. But with the Mac Pro, the software is older and only has Boot Camp 2.0, thus I'm wondering if I can simply use the software on the general copy of Snow Leopard I own, or does the silver disc contain specific drivers for my Mac Pro that I need?
    I'm under perhaps the wrong impression that the silver discs that you get with your Mac purchase contain drivers for your specific Mac model which you can't get from the general Snow Leopard disc.
    Thanks.

  • HT1725 Helo I need help fixing my I-tune account.  Anyone out there?

    Hello I need Help fixing my I tune account is anyone out there?

    You do not state your issue...
    KHarenda wrote:
    ... I need Help fixing my I tune account ...
    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • I need help fixing my iPod Touch 4th Generation myself

    I have an iPod Touch 4th Generation and the home button isn't working i think its stuck problem is my warranty expired and i have no money to fix it so i need help fixing it myself again my warranty expired and i have no money to fix it so HELP PLEASE

    Try:
    fix for Home button
    iPhone Home Button Not Working or Unresponsive? Try This Fix
    - If you have iOS 5 and later you can turn on Assistive Touch it add the Home and other buttons to the iPods screen. Settings>General>Accessibility>Assistive Touch
    - If not under warranty Apple will exchange your iPod for a refurbished one for:
    Apple - Support - iPod - Repair pricing
    You can do it an an Apple store by:
    Apple Retail Store - Genius Bar
    or sent it in to Apple. See:
    Apple - Support - iPod - Service FAQ
    - There are third-party places like the following that will repair the Home button. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens

  • When trying to install Aid Virtual Instruments I get a warning no mountable file systems. I need help fixing the problem.

    When trying to install Pro Tools 10.3.3 Aid Virtual Instruments I get a warning no mountable file systems. I need help fixing the problem.

    Thanks Linc for responding to my post. I searched a little further and found I was missing a file. Once I downloaded the fix, I was able to install the software from the original download.

  • I need help with my code..

    hi guys. as the subject says I need help with my code
    the Q for my code is :
    write a program that reads a positive integer x and calculates and prints a floating point number y if :
    y = 1 ? 1/2 + 1/3 - ? + 1/x
    and this is my code
       This program that reads a positive integer x and calculates
       and prints a floating point number y if :
                 y = 1 - 1/2 + 1/3 - ? + 1/x
       import java.util.Scanner; // program uses class Scanner
        class Sh7q2
           // main method begins execution of Java application
           public static void main( String args[] )
          // create Scanner to obtain input from command window
             Scanner input = new Scanner( System.in );
             int i = 1; // i is to control the loop
             int n = 2; // n is suppose to control the number sign
             int x; // a positive integer entered by the user
             int m;
             System.out.println("Enter a positive integer");
             x = input.nextInt();
             do
                m = (int) Math.pow( -1, n)/i;
                System.out.println(m);
                   n++;
                   i++;
             while ( m >= 1/x );
          } // end method main
       } // end class Sh7q2 when I compile it there is no error
    but in the run it tells me to enter a positive integer
    suppose i entered 5
    then the result is 1...
    can anyone tell me what's wrong with my code

       This program that reads a positive integer x and calculates
       and prints a floating point number y if :
                 y = 1 - 1/2 + 1/3 - ? + 1/x
       import java.util.Scanner; // program uses class Scanner
        class Sh7q2
           // main method begins execution of Java application
           public static void main( String args[] )
          // create Scanner to obtain input from command window
             Scanner input = new Scanner( System.in );
             int i = 1; // i is to control the loop
             int n = 1; // n is suppose to control the number sign
             int x; // a positive integer entered by the user
             double m;
             int a = 1;
             double sum = 0;
             System.out.println("Enter a positive integer");
             x = input.nextInt();
             for ( i = 1; a <= x; i++)
                m =  Math.pow( -1, n+1)/i;
                sum  = sum + m;
                n++;
                a++;
             System.out.print("y = " + sum);
          } // end method main
       } // end class Sh7q2is it right :S

  • Well my ipod 4th gen was updated it shut off and now when i try to turn it on it stays on the apple logo for abit then gets stuck on a white screen od blue or mixed colores i really need help fixing this plzz help :(

    Well my ipod 4th gen was updated it shut off and now when i try to turn it on it stays on the apple logo for abit then gets stuck on a white screen od blue or mixed colores i really need help fixing this plzz help

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

Maybe you are looking for

  • Mixing ram sticks

    Hi nForce people Tricky question to ask. As you can see in my specs, I've 512 Mb Kingston DDR Ram pc 3200.... and an nForce2 mobo. Which may seem not so nice a mix, but it's working fair. The point is that I'd like to have 1 Gb ram and this is troubl

  • An unexpected error has been detected by HotSpot Virtual Machine:

    Hi When I upload the xml file with dubug window. When I have debug then this message will come.. So give me a solution.. Here at below I have pasted files. in which I want to by pass the ldap.. So give me suggestion what to do with that files. What's

  • Help Plz Deadline! - Large PNG Wont Open in Illustrator

    Could someone who knows please help as soon as possible I have two versions of a PNG file, one in medium size and the other in XLarge size for print... The medium opens fine but as its for print i need the XLarge to open I have found no way to get it

  • What table column size is needed to accomodate Unicode characters

    Hi guys, I have encounter something which i dont understand and i hope gurus here will shed some light on me. I am running a non-unicode database and i decided to port the data over to a unicode database. So 1) i export the schema out --> data.dmp 2)

  • WRT54GS V7 128 BIT ENCRYPTION

    I just this morning bought a new wireless router, ran home and hooked it up.  I have had 3 other Lynksys (wired) routers in the past, do all my own work from mechanical to software and LAN. The initial setup went fine with the first desktop PC, runni