Need help again. please

This is my code for the game called Pig. I asked help before and I fixed it. But it still doesn't seem to work.
I need it to jump from the loop where answer = y to the next loop where answer = n.
Which part is wrong in my program?
Any help will be appreciate. Thank you.
public class Pig
    public static void main (String[] args)
      String answer="y";
      int num3=0, num6=0; 
      PairOfDice die1 = new PairOfDice(); // die # 1
      PairOfDice die2 = new PairOfDice(); // die # 2
      while (num3 <= 100 || num6 <= 100)
      while (answer.equalsIgnoreCase("y"))
            rollUser();
            System.out.println ("Do you want to roll again? (y/n)");
            answer = Keyboard.readString();
      while (answer.equalsIgnoreCase("n"))
            rollComputer();
            System.out.println ();
            answer = "y";
    public static void rollUser ()
        int num1, num2, num3 = 0, two = 2;
        PairOfDice die1 = new PairOfDice(); // die # 1
        PairOfDice die2 = new PairOfDice(); // die # 2
        num1 = die1.roll();
        num2 = die2.roll();
        while (two == 2)
          if (num1 == 1) // when either face is 1
             {num3 = num3;
                 two = 1;
          if (num2 == 1)
             num3 = num3;
                 two = 1;}
          else  
              if (num1 == 1)
                  if (num2 == 1) // when both faces are 1
                 {num3 = 0;
                     two = 1;}
              else
                  num3 += num1 + num2; // sum of two faces
        System.out.println (num1 +" "+ num2); // shows both faces
        System.out.println (num3);   
    public static void rollComputer()
        int num4, num5, num6 = 0, one = 1;
        PairOfDice die1 = new PairOfDice(); // die # 1
        PairOfDice die2 = new PairOfDice(); // die # 2
        String answer="n";
        num4 = die1.roll();
        num5 = die2.roll();
       while (one == 1)
          if (num4 == 1) // when either face is 1
             {num6 = num6;
                 one = 2;
          if (num5 == 1)
             num6 = num6;
                 one = 2;}
          else  
              if (num4 == 1)
                  if (num5 == 1)// when both faces are 1
                 {num6 = 0;
                     one = 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
          if (num6<=20)
             {one=2; answer = "y";}
     

I need it to jump from the loop where answer = y to the next loop where answer = n.And would you like to tell us what happens instead?
-- as the code stands, your second loop will never repeat, so should not be a while loop but rather an if block.
-- or maybe you wanted to assign the value of answer in rollComputer, but instead you declared a local variable, which you assign values to but never test.
db

Similar Messages

  • Display presenter's note! Need help again Please

    Since installing leopard I cannot see the presenter's note on my screen and the slide on the projector's screen. I had wonderful advice in the past on how to do it in Tiger, I tried every configuration possible and I cannot do it.
    When I click off mirror I can see the slide on the screen but not on my laptop all I see is the empty desktop. If I choose to see presenter's display then my audience sees both slides and my notes.
    What am I doing wrong?
    Thank you for any help you might give me.
    Mireille

    Hi Mirelle,
    I think you need to make sure, that your notebook have found the attached monitor/projector before you begin the presentation, that way when switching off mirroring you should get a perfect picture on both monitor and projector.
    To see the notes, please be aware, that you manually have to enable notes. If you have chosen the outline view and writes here, it is not presentaed as notes. In the View menu chose show presenter notes, and now you can write your notes here, and they will be displayed during presentation at the presenter display.
    --Klaus

  • News "FLASH"... Nancy O (the legend) ... i need help again

    I am trying to put a banner on my website for my exam.... It will have to have an image with logos flashing across and stopping for a few seconds before carrying on.and out the other side.  I have looked up everywhere to see how this is done but with no joy. There is lots of info out there but it is not working for me.  In Flash i have no problem creating a banner image with various logos moving  from one side to the other or even changing the image from one shape to another or bouncing it up and down the stage from one side to the other. I can even stagger the timelines for the logos to make them enter one after the other. The one thing i can not get to grips with is making the images stop or pause after they have entered from one side before exiting  the other side. I have followed step by step many  youtube tutorials but the authors are wizzing through them too fast and despite folling every step second by second, i  am missing a vital step somewhere.   Would someone please let me know step by  step (and please assume i am an idiot when doing this) the sequence i must follow from the very begining to the last step when i publish.

    Noooooooo........ When i saw your email notification i had high hopes of getting the answer i have been trying to work out for two days....but no problem ..your still a legend ha ha ... you got me out of a big hole in this project the last time... but thanks for taking the time to reply, i will try the other forum.
    Date: Thu, 26 Jan 2012 17:28:18 -0700
    From: [email protected]
    To: [email protected]
    Subject: News "FLASH"... Nancy O (the legend) ... i need help again
    Re: News "FLASH"... Nancy O (the legend) ... i need help again created by Nancy O. in Dreamweaver - View the full discussion
    You'll get better answers in the Flash Forums for whichever Action Script ver you're using.
    Sorry.  I don't do much Flashy stuff anymore.  As far as I'm concerned, when Apple iDevices quit supporting Flash, it became a dying web technology.  
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4167793#4167793
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4167793#4167793. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Dreamweaver by email or at Adobe Forums
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Need Help again...

    Hi all...
    Really need help again this time...
    I am trying to do a web page and thought of placing 4 video
    clips into
    1 Loader...viewers can simply choose any of the videos they
    would like
    to watch...and all the video clips will then play in the same
    Loader on
    the exact X & Y values...Is it possible?
    eg. 4 Buttons with linking to 4 different video clips.
    When a video clip selected, play in a Loader of X and Y
    values.
    When another clip selected, play in the same Loader.
    Moca or anyone...please help me a.s.a.p...Thanks in
    advance...

    Does this happen to a wired computer or to a wireless computer? If it happens to a wireless computer ONLY but not to a wired computer, a firmware upgrade might not be necessary at all.
    Make sure your wireless settings are personalized, try using channel 11 and when you go to advanced wireless settings, try setting the beacon interval to 50 instead of 100.
    On how to do the things mentioned in the 2nd paragraph, open up IE and type on the address bar the numbers 192.168.1.1 (username leave it blank, password as a default is admin). Go the the Wireless tab.

  • My screen is completely white, i've tried holding lock and home buttons as seen on you tube something called 'white screen of death' its goes black (think it switches off) then back to the white screen need help fast please!

    my screen is completely white, i've tried holding lock and home buttons as seen on you tube something called 'white screen of death' its goes black (think it switches off) then back to the white screen need help fast please!

    If you have not done a factory reset on the device, I recommend doing a complete  factory reset.  
    Factory Reset  - Warning this will reset device back to original factory settings.
    This method will not erase any MDN/MIN information
    Turn off the phone 
    Press Power + Volume Up/Down at the same time and hold until display will show a triage android screen 
    Display will show: 
    Reboot system Now 
    Apply sdcard:update.zip 
    Wipe Data/Factory Reset 
    Wipe Cache Partition
    Use VOL Down key to scroll down to "Wipe Data/Factory Reset", press home icon to select option and wipe device. 
    Display shows "All user data will be wiped out", press VOLUME Up to continue or VOLUME Down to exit. 
    Press Volume Up 
    Press Home to select "Reset System Now" - device will reboot
    If the problem persist I recommend having a store technician take a look at the device.
    Copy and paste the link below into your browser's address bar for the store locator.  
    http://www.verizonwireless.com/b2c/storelocator/index.jsp

  • I need help quick please sold the iPod and before handing it over wanted to clear out info so pushed erase now there is only a plug icon for iTunes but it won't now recognize my computer what can I do??

    I need help quick please sold the iPod and before handing it over wanted to clear out info so pushed erase now there is only a plug icon for iTunes but it won't now recognize my computer what can I do??

    Try
    iOS: Device not recognized in iTunes for Windows
    or
    iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X

  • Re: help again please

    Check your braces for your 'if' statements. I don't think they are what you intended. You only update carmake if the car is a mercedes.
    Please use more descriptive subject titles. "Help again please", "help appreciated", and "just cant work this out" could describe 99% of the threads on this forum. Maybe something like "Why is this an infinite loop?" would be useful.

    import java.io.*;
    import java.util.*;
    public class TestPlan
       public static void main(String args[])throws FileNotFoundException
          Scanner inFile = new Scanner(new FileReader("c:\\praccc.txt"));
          PrintWriter outFile = new PrintWriter("c:\\cars.out.txt");
          String carMake = inFile.next();
          outFile.println("Enter make [* ends]:> " + carMake);
          int age = inFile.nextInt();
          outFile.println("Enter age:> " + age);
          int daysHired = inFile.nextInt();
          outFile.println("Enter no. of days hired:> " + daysHired);
          int kmsTravelled = inFile.nextInt();
          outFile.println("Enter kms travelled:> " + kmsTravelled);
          while(!carMake.equals("*"))
                carMake = inFile.next();
                outFile.println("Enter make [* ends]:> " + carMake);
                age = inFile.nextInt();
                outFile.println("Enter age:> " + age);
                daysHired = inFile.nextInt();
                outFile.println("Enter no. of days hired:> " + daysHired);
                kmsTravelled = inFile.nextInt();
                outFile.println("Enter kms travelled:> " + kmsTravelled);
                inFile.close();
                outFile.close();
    }ok sorry im not very experienced with java as you can tell but if this question doesnt solve my prob I think I will give up. The code above which i have broke up still gives me NoSuchElementException. The file praccc.txt simply contains....
    mercedes 10 100 100
    mercedes 20 200 200
    mercedes 30 100 200
    mercedes 30 200 100
    mercedes 20 130 200
    *

  • Sound trouble need help urgent please

    Could somebody tell me how i can fix my problem.
    problem: when my curve 8520 is in silence profile en i start typing in a phnoe number i hear nothing,
    but when my phone is in normal profile i hear i beep with every number of the phone number i enter.
    so i want to know how i can stop my bb from making this noise

    My friend it is a fillable form, can i email you the pdf that iam trying to fill out? then would you be able to tell me how to do it please mate?
    I have attached the form, i need to fill in those boxes so that everything is accuratly height + spacing is correct, and to do it fast, thats all im after.
    Date: Sun, 27 Jun 2010 18:31:58 -0600
    From: [email protected]
    To: [email protected]
    Subject: Need Help Urgent Please
    If is a fillable form, just tab to the next field. What we do not understand from you is IF it is a fillable form or not. If it is not, then the 3 options I gave can be used. Placing text is always a problem. You might find it useful to turn on the grid to help in placing your typewriter fields. However, if it is fillable you do not have to create any fields to type in, you just leave the tool as the hand tool and select the predefined fields with the cursor or the tab key and type accordingly. If the field is a checkbox, then you just use the space key to activate it.
    So, are we talking about a fillable form or something that has the appearance of a form, but not fields to fill in. This is what Bernd has been try to find out and you keep suggesting it is fillable as we read what you have said.
    >

  • ITunes Error Message. Still need help. Please.

    I still haven't been able to use my ITunes for about two months. I need help to fix the problem. Here's what it says when I try to start ITunes:
    Microsoft Visual C+ + runtime library
    Runtime Error!
    Program: C:\program files\itunes\itunes.exe
    This application has requested to terminate in an unusual way. Please contact the application’s support team for more information.
    If anyone can help me with this I would greatly, greatly appreciate it. Thanks.
      Windows XP  

    Have you tried un-installing iTunes, downloading the program again from Apple, and re-installing?
    It's always worth a try, as it should help you clear off anything causing the problem and start again.

  • Ink cartridges stuck, need help asap please

    Hello a I am writint this because I need help!! I keep getting a message in error on my Macbook Pro about my Photsmart 6520 is jammed and it says to check to see if any obstructions are bloacking it. Hoever this is like the 20th time that I check inside the printer over and over again. I make sure everything is in order, however when I turn the printer back on it will say the same thing and I keep trying to get it to work, but it won't!!! I just got the printer the day before yesterday and I caanot fix it, please help it is urgent.
    This question was solved.
    View Solution.

    The troubleshooting steps in the document here may help resolve the carriage jam message on your Photosmart 6520 printer.  If the steps there do not resolve the issue I suggest you contact HP support.  If you are in the US or Canada call 1-800-HPINVENt, elsewhere see the contact information here.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Need Help Fast Please

    Why does this code not do what I want to happen?
    I have a 7 non functional buttons above the buttons for the days in the month and I would like to be able to layout the buttons starting on the day that the month begins and ending where it ends.
    Like in the microsoft windows calander.
    Any ideas as to how I'd do this?
    I need help fast. Please.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    public class MyDairy extends JFrame
         //Initilises Global Variables
         myHandler H = new myHandler();
         monthHandler J = new monthHandler();
         openHandler O = new openHandler();
         String monthName;
         JComboBox months;
         static String[] daysOfWeek = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
         static int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 
         JFileChooser box;
         public MyDairy()
              //Initilises the JComponents
              JMenuBar menuBar;
               JMenu menu;
              JMenuItem menuOpen;
              JMenuItem menuSave;
              JMenuItem menuExit;
              JButton dayName[] = new JButton[7];
              JButton day[] = new JButton[36];
              JPanel b;
              JPanel a;
              Calendar today = Calendar.getInstance();
              Calendar startOfMonth = Calendar.getInstance();
              startOfMonth.set(Calendar.DAY_OF_MONTH,1);
              startOfMonth.set(Calendar.DAY_OF_WEEK,7);
              System.out.print(startOfMonth);
              //Sets up the Layout
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container c = getContentPane();   
              c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
              a = new JPanel();   
              a.setLayout(new GridLayout(0, 7));
              b = new JPanel();   
              b.setLayout(new GridLayout(5, 7));
              //Sets up and adds the menu bar   
              menuBar = new JMenuBar();   
              setJMenuBar(menuBar);  
              //Adds the File menu
              menu = new JMenu("File");   
              menuBar.add(menu);
              //Adds the menu items      
              menuOpen = new JMenuItem("Open");     
              menu.add(menuOpen);
              menuSave = new JMenuItem("Save");     
              menu.add(menuSave);
              menuExit = new JMenuItem("Exit");     
              menu.add(menuExit);
              //Produses the ComboBox
              String[] name={"January", "Feburary", "March", "April", "May", "June", "July", "Augest", "September", "October", "November", "December"};
              months = new JComboBox(name);
              int m = today.get(Calendar.MONTH);
              int d2 = today.get(Calendar.DAY_OF_WEEK);
              System.out.print(d2);
              months.setSelectedIndex(m);
              months.addActionListener(J);
              c.add(months);
              c.add(Box.createVerticalStrut(10));
              switch (months.getSelectedIndex())         
                       case 0: for (int i=1; i<36; i++)                          {                   
                         if(i<4)                
                            day[i] = new JButton();                  
                            day.setEnabled(false);               }               
    int k = 1;                
    day[i] = new JButton(" "+k);                b.add(day[i]);                
    day[i].addActionListener(H);               k++;               
    }break;          
    //other case statement up to 11 are simaliar          }                     
    c.add(a);
              //Produces an Array of Buttons
              for (int i=1; i<36; i++)
                   day[i] = new JButton(" "+i);
                   b.add(day[i]);      
                   day[i].addActionListener(H);               
              c.add(b);
              updateNameField();
              setSize(400,400);
              show();
         }//constructor
         private void updateNameField()
              monthName = (String) months.getSelectedItem();
         class myHandler implements ActionListener
              public void actionPerformed(ActionEvent e)
                   new Text_Area(monthName);
         class openHandler implements ActionListener
              public void actionPerformed(ActionEvent e)
                   File f1 = New File ("2003.dat");
                   simpleSerializer S = new simpleSerializer(f1);
                   MyDairy = S.readObjectFromFile();
         class monthHandler implements ActionListener
              public void actionPerformed(ActionEvent e)
                   updateNameField();
         public static void main(String[] args)
              new MyDairy();

    Container c = getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));don't code like above try something like...
    Box box=Box.createVerticalBox();
    c.add(box);
    ----so on
    Hope this will help...

  • So i have Two account on my imac OS X Lion 10.7.5 and dont have administrator and its locked need help asp please Someone!

    I have a Imac and i cant acces adminastrator Becuase my two users dont have becuase i took them i dident know that would happen and need help i dont wanna loose all the stuff in the imac so if you can help please message me asp

    Use the directions given here:
    http://osxdaily.com/2011/08/24/reset-mac-os-x-10-7-lion-password/

  • I need help urgent please :(

    Hi i'm too much worried about my laptop because before 1 hours its working perfectly and while i working on my laptop suddenly laptop is off and now when i presss power on button its on for 4 seconds with a fast fan voice and no display on screen and then again off what i do can any one help me please thansk a lot advanced....
    Regards,
    Osman

    Please diagnose your PC using the detailed instructions in the link below.
    The "HP PC Hardware Diagnositcs" will test all the hardware components of your PC.
    Testing using HP PC Hardware Diagnostics (UEFI)

  • I have just reset my password about a hundred times and still the facetime and I messenger is not accepting my password, I previously had FaceTime working now nothing is happening, I need help now please

    I have just reset my password about a hundred times and still the face time and I messenger is not working, I previously used FaceTime once and now I need help urgently
    What am I not doing?

    Hi fatbear711.  are the following as follows?  Settings/restrictions:  Facetime and Camera are both ON?   Also in Game centre at bottom 'Adding Friends" is turned on?  If all ok, log into your account via itunes App, Click on your ID at bottom left of say the Music page, then click to 'Manage', enter password.  On next page click on your apple ID at top, then select to go to '[email protected]'. Log in on the browser window page that appears and confirm that your primary apple ID and primary email have been verified (should have green ticks and the word 'verified' next to them.  If you use itunes on a pc to sync with then do this through iTunes;Store menu on your pc, ensuring that you sync your device once finshed.  You will also need to check that your device is set to the correct timezone and time in your devices settings page.  If problem still persists at least we'll know the basics are ok.
    When you post again can you also include whether ipad2/3 etc and iOS e.g. 5.3.1/6.01 etc
    Best regards
    Nick

  • Error Message and Itunes won't open. NEED HELP ASAP PLEASE

    I tried to get into my iTunes from my desktop short cut and the error message saying "Problem with Shortcut" then saying "This action is only valid for products that are currently installed." ***??? Anyway I tried to download a new version of iTunes then it said it could no remove old files. SO, I tried to remove iTunes by add/remove programs and it won't let me.>> NEED HELP I LEAVE TOMORROW FOR TRAINING AND I NEED SOME MUSIC AND UPDATE ON MY IPOD>>>>

    Welcome to AD!
    Download, install, and run this tool from Microsoft. Use it to fix the iTunes and QuickTime programs, as well as Apple Software Updater.
    http://support.microsoft.com/kb/290301
    Then reinstall iTunes.
    If you need step-by-step directions, they are in the *General installation troubleshooting* section of this Apple article. Click on each line to expand the instructions.
    http://support.apple.com/kb/HT1926
    The Microsoft installer cleanup tool is listed in the third step, "Clean up iTunes installer files on the computer".

Maybe you are looking for

  • Getting user OID info

    Hello: I need to get more info from a user inside a portlet. I can get username and DN from a user that has logged in portal from my portlet, but when I call another fuctions like getFirstName, getLastName or getPropertyValue I always get null values

  • Appraisal document header not showing up in the Portal

    when I look at the appraisal document in Portal ESS MSS (using WD4A application Appraisal Document) the header of the appraisal document does not show up (in PHAP_ADMIN it does). how can I show the appraisal document header in the Portal? regards, Ti

  • Create a Lightbox | Adobe Muse Feature Tour | Adobe TV

    Create an overlay that brings special focus to an image, video or other content by having it appear in a modal layer. http://adobe.ly/I5cSgq

  • Rotate position of JProgressBar component

    Dear All, I am new in javafx for animation. I am using JProgressBar component for describe the progress, but I want to rotate the bar to the vertical position thus the progress flow from bottom to up ( not left to right or it reverse). Any suggestion

  • Custom Fields for Content Search WebPart

    I created a custom item display template to control the look of the data.  I copied the template "Picture on left, 3 lines on right" and just rearranged the div and added my own styles.  I created a custom List for Company Information.  The list cons