Very Simple Problem-- Need help in method selection process

Hello,
It's difficult to explain the background of the program I am making-- but I am stuck at a very simple problem, that I can only solve with a very long block of if statements:
I have 3 possible numbers-- 1, 2, or 3.
Imagine two numbers are already taken-- say 1 and 2. I want a variable to set itself to the number that's not taken (3).
So, again: If two numbers were taken say 2 or 3-- I want the variable to be sent to the other one that isn't taken-- 1.
Thank you for your help,
Evan.

Actually, I'll just tell you the context of the program-- here is what I have so far:
This program is meant to simulate Monty Hall Problem:
http://en.wikipedia.org/wiki/Monty_Hall_problem
The program sets up an array of three possible values. Each one of those values represents a door with either a goat or a car behind it. It then randomly sets one of those values to 1 (in order to represent a car as per the Monty Hall problem), and 0's represent goats.
The user, which is simulated by the program (does not involve actual interaction), chooses a door initially.
The game show hosts then reveals a door that is not the users initial choice, but IS a goat ( an array value of 0).
For example if the array was [0][0][1]
The user could pick door one (array position 0). Which is a goat.
The game show host then reveals a goat that is not the users choice-- which would be array position 1.
After the game show host reveals the goat-- I want the user to always switch his decision to the only other remaining door that was not his first choice.
Then I wanted the computer to test to see if his final choice is the one with a car. And to tally up the amount of times he got it right.
--Sorry that was long winded:
import TerminalIO.*;//imports TerminalIO package for system.out.println
import java.util.*;//import java.util for random
public class Monty_Problem
     int doors[]= {0,0,0};
     Random rand= new Random();
     double wins,totals=0;
     public void carAssignment()
          int car_door= rand.nextInt(3);
          doors[car_door]=1;
     public int judgesChoice(int judgeDoor, int initialChoice)
          if(judgeDoor != initialChoice && doors[judgeDoor]!=1)
               return judgeDoor;
          else
               return judgesChoice(rand.nextInt(3), initialChoice); //infinite loop right here that I cannot remedy.  I want the program to have the judge pick a location that is not occupied by a  '1' and is not the user's choice. 
     public void gamePlaySwitches()
          int initialChoice= rand.nextInt(3);
          int judgeDoor = 0;
          int secondChoice= 0;
          judgeDoor= judgesChoice(rand.nextInt(3), initialChoice);
          //This part is meant to have the user switch choices from his initial choice
               // to the only other choice that hasn't been revealed by the judge. 
          while(secondChoice == initialChoice || secondChoice== judgeDoor)
               secondChoice++;
          if(doors[secondChoice]==1)
               wins++;
               totals++;
          else
               totals++;          
     public static void main(String [] args)//creates the main menu
          Monty_Problem a= new Monty_Problem();
          int games=0;
          while(games!=100)
                    a.carAssignment();
                    a.gamePlaySwitches();
                    games++;
          System.out.println(a.wins/a.totals);
}Edited by: EvanD on Jan 11, 2008 4:17 PM

Similar Messages

  • I tell her that I'm developing a flash content with as2 and I have a very simple problem, I hope you

    Hello, how are you?
    I tell her that I'm developing a flash content with as2 and I have a very simple problem, I hope you can help me
    I happened to create a movie clip and inside to create a scroll that is two isntancias,
    I mean:
    in the first frame create a button in the 6 to 5 buttons and an action to melleve the sixth frame and another to return. (Elemental truth)
    Now I have a problem. In creating a movie clip instance name to each button and in the average place the next fram as2,
    boton.onRollOver name = function () {
           gotoAndStop ("Scene 1", "eqtiqueta");
    because what I want is that from inside the movie clip, go to the scene proncipal to a frame that is three in the label name.
    however, does not work.
    appreciate your cooperation.
    Escuchar
    Leer fonéticamente
    Diccionario - Ver diccionario detallado

    Hello, I think you need to start a discussion on the Action Script forum. This is the Flash Player forum, the browser plugin.
    Thanks,
    eidnolb

  • This is detailed: I lost my touch pad scroll ability on my desktop when I installed Firefox, I am having a terrible time trying to sync my new Android tablet to my desktop, my desktop Firefox is acting very strangly (I need help trying to use it)

    My Vista Home Premium desktop has not used Firefox for a long time. I just loaded it as well as on my Honeycomb Android. The statement that I made pretty much says what my problem is. I can use both of them at the same time and use a router with the air Verizon card installed.
    I'll repeat my question: This is detailed: I lost my touch pad scroll ability on my desktop when I installed Firefox, I am having a terrible time trying to sync my new Android tablet to my desktop, my desktop Firefox is acting very strangely (I need help trying to use it)

    My Vista Home Premium desktop has not used Firefox for a long time. I just loaded it as well as on my Honeycomb Android. The statement that I made pretty much says what my problem is. I can use both of them at the same time and use a router with the air Verizon card installed.
    I'll repeat my question: This is detailed: I lost my touch pad scroll ability on my desktop when I installed Firefox, I am having a terrible time trying to sync my new Android tablet to my desktop, my desktop Firefox is acting very strangely (I need help trying to use it)

  • I am un able to send mail as it gets stuck in my outbox. I am sure the solution is simple but need help?

    I am un able to send mail as it gets stuck in my outbox. This is a recent phenomena. I am sure the solution is simple but need help?

    I looked everywhere for a solution - and I finally figured it out! Deleting my accounts didn't work, but here is what worked. This worked when my Gmail accounts were not sending properly. I'm not sure if it works for other e-mail services.
    1. While in Mac Mail, click "Mail" in the top left corner of the screen
    2. Click "Preferences"
    3. Click "Accounts"
    4. Select your account that isn't sending properly
    5. In "Outgoing Mail Server (SMTP)" there will be two options - Gmail & Gmail (offline)
    Make sure that "Gmail" is selected and NOT "Gmail (offline)"
    If you navigate to another section in Preferences, it will ask you to SAVE - make sure you save your changes!
    It worked for me, hope it works for you!

  • I need help with a SELECT query - help!

    Hello, I need help with a select statement.
    I have a table with 2 fields as shown below
    Name | Type
    John | 1
    John | 2
    John | 3
    Paul | 1
    Paul | 2
    Paul | 3
    Mark | 1
    Mark | 2
    I need a query that returns everything where the name has type 1 or 2 but not type 3. So in the example above the qery should bring back all the "Mark" records.
    Thanks,
    Ian

    Or, if the types are sequential from 1 upwards you could simply do:-
    SQL> create table t as
      2  select 'John' as name, 1 as type from dual union
      3  select 'John',2 from dual union
      4  select 'John',3 from dual union
      5  select 'Paul',1 from dual union
      6  select 'Paul',2 from dual union
      7  select 'Paul',3 from dual union
      8  select 'Paul',4 from dual union
      9  select 'Mark',1 from dual union
    10  select 'Mark',2 from dual;
    Table created.
    SQL> select name
      2  from t
      3  group by name
      4  having count(*) <= 2;
    NAME
    Mark
    SQL>Or another alternative if they aren't sequential:
    SQL> ed
    Wrote file afiedt.buf
      1  select name from (
      2    select name, max(type) t
      3    from t
      4    group by name
      5    )
      6* where t < 3
    SQL> /
    NAME
    Mark
    SQL>Message was edited by:
    blushadow

  • Need help in optimizing the process

    I need help in optimizing my process. Here is what am I doing:
    I have two tables table A and table B. table A has list of names and table B has name and ID. Right now I am loading name into cursor from table A and for each name from the cursor I try to match with name in table B to get the ID. This process takes very long to complete. I need help to replace PL/SQL with SQL if possible. I am using oracle utl_match to match the best possible record in table B. table B sometimes returns multiple matching records. I take the top nearest match name and ID for my use (there is not always one to one match)
    Any idea or help will be appreciated. Thanks

    always provide create table and sample data instert statements when asking a question. also, provide your database version.
    because you're using utl_match, you can't really use an index, there must be a cartesian join on the two tables so it may always be slow.
    however, here's a sample SQL that you may be able to make use of:
    with n as (select 'KATHERINE' person_name from dual
                 union all
                 select 'STEVE' from dual
                 union all
                 select 'BRUCE' from dual)
        ,nid as (select 'CATHERINE' person_name, 1 NID FROM DUAL
                 union all
                 select 'STEFAN', 2 from dual
                 UNION ALL
                 select 'STEVEN', 2 from dual
                 union all
                 select 'CATHY',3 from dual)
    select n_name, nid
      from (
            select n.person_name N_NAME
                  ,nid.person_name
                  ,nid.nid
                  ,ROW_NUMBER() OVER (partition by n.person_name ORDER BY utl_match.jaro_winkler_similarity(n.person_name,nid.person_name) DESC) jws_ORDER
              from n
              join nid on (utl_match.jaro_winkler_similarity(n.person_name,nid.person_name) > 70)
      where jws_order = 1;    

  • Need help for interface to process employee expenses

    need help for interface to process employee expenses
    i have used the interface tables as
    AP_INVOICES_INTERFACE
    AP_INVOICE_LINES_INTERFACE
    are they the right one
    is there a concurrent program or any API for doing interface

    hi,
    i think what ever table are using for interfacing expenses correct.
    but you have to enter invoice type as expense report.
    Regards,
    Srikanth

  • Need help with db select

    As usual I have been stuck for a while on what is probably a very simple solution so perhaps someone can help me, thanks.
    I have a portfolio page to which I post a url to filter the portfolio type (0, 1 or 2) and display the results.
    It works ok except that I can't get the url right to show all records. I have tried things like
    /portfolio.php?websitetype=1&2
    and
    /portfolio.php?websitetype=*
    /portfolio.php?websitetype>0
    Perhaps I need to change my select?
    $query_portfolio = "SELECT * FROM portfoliodb WHERE portfoliodb.websitetype='". $_GET['websitetype'] ."'  AND portfoliodb.visible = 1 ORDER BY portfoliodb.portfolio_id DESC";

    bikeman01 wrote:
    Ok I've now got it working as suggested so that's a big improvement, thanks but it's not quite what I was after. What I want is for all records to be retrieved by default when there is no url suffix and not require ?websitetype=ALL
    That is not what your OP asked for!
    It works ok except that I can't get the url right to show all records. I have tried things like
    /portfolio.php?websitetype=1&2
    and
    /portfolio.php?websitetype=*
    /portfolio.php?websitetype>0
    // determine if the URL parameter for websitetype is set.
    if (isset($_GET['websitetype'])) {
                   // run a query to filter only selected types
                   // based off value of URL parameter
                        $query_portfolio = "SELECT *
                        FROM portfoliodb
                        WHERE portfoliodb.websitetype='". $_GET['websitetype'] ."'
                        AND portfoliodb.visible = 1
                        ORDER BY portfoliodb.portfolio_id DESC";
    // else if the URL parameter for websitetype is not set.
    } else {
                        //  run query to display ALL types
                        $query_portfolio = "SELECT *
                        FROM portfoliodb
                        ORDER BY portfoliodb.portfolio_id DESC";
    // end condition if the URL parameter for websitetype is set.

  • Major iPod Problems, Need Help Solving

    One day I was casually syncing my iPod video with my computer to get a few new songs uploaded onto it.
    Suddenly, the iPod freezes up, shuts itself off, restarts, and magically it has forgotten everything and pretends it is a brand new iPod.
    No problem, I think, believing it will just need to load the songs again and everything will be fine.
    However, this is not the case.
    The iPod would then continue to load all the songs, shut down after loading them, restart and again pretend it is brand new and lad all the songs again.
    This continues to happen again and again.
    I try to update my iPod, figuring it may just be a version error or somesuch nonsense. The updater refuses to work and actually causes my iPod to crash, saying it has a diskwrite error.
    It refuses to "System Restore" on my computer, so I run the "System Restore" on another window computer that I own. And it runs just fine, making the iPod load songs once more.
    And I think, problem solved!
    However, again, this is not the case.
    I load it once, everything goes fine.
    The nxt day, after buying more songs, I try to upload and after the upload, the iPod shut off, restarts, and pretends to be new once more.
    I go through the "System Restore" process again, but afterwards, the iPod all out refuses to upload my music fully, shutting off about halfway through the process each time.
    And now whenever it is plugged into my computer, windows says it is unreadable and must be reformatted, so I run the updater and it says that there is an "iPod manager internal error" which could basically be another language considering my only basic knowledge of computers.
    Is there any way to repair my iPod at home? Or must it be sent in to Apple?

    GREAT NEWS!
    Last night, through some very thorough digging in the
    "Search Discussions", I found the answer and now my
    iPod is running perfect once more!
    Thank you very much for your help b noir. Without
    you, and many others on this board who had their
    problems solved by equally helpful people, I would
    still be digging through Apple's support section to
    no avail.
    PS. I found the answer in http://discussions.apple.com/thread.jspa?message
    ID=1539429

  • Still stuck with the same old producer consumer weight problem need help

    Hello All,
    This is the problem I am stuck with right now.
    I have two array lists one producer array list and one consumer array list denoted by a and b
    P1 P2 P3 P4 P5
    5 6 7 8 9
    C1 C2 C3 C4 C5
    2 3 4 5 6
    Now we find all those producer consumer pairs which satisfy the criteria Pi>=Ci
    We have the following sets
    (5,2)(6,2)(7,2),(8,2),(9,2)
    (5,3)(6,3)(7,3),(8,3),(9,3)
    (5,4)(6,4)(7,4),(8,4),(9,4)
    (5,5)(6,5)(7,5),(8,5),(9,5)
    (6,6)(7,6)(8,6),(9,6)
    Let us done each of them with Si
    so we have S1,S2,S3,S4,S5
    we assign a third parameter called weight to each element in Si which has satisfied the condition Pi>=Ci;
    so we we will have
    (5,2,ai),(6,2,bi),(7,2,ci)....etc for S1
    similarly for S2 and so on.
    We need to find in each set Si the the pair which has the smallest weight.
    if we have (5,2,3) and (6,2,4) then 5,2,3 should be chosen.We should make sure that there is only one pair in every set which is finally chosen on the basis of weight.
    Suppose we get a pair (5,2,3) in S1 and (5,2,3) in S2 we should see that (5,2,3) is not used to compare to compare with any other elements in the same set S2,
    Finally we should arrive at the best element pair in each set.They should be non repeating in other sets.
    Given a problem
    P0 P1 P2 P3 P4
    9 5 2 2 8
    6 5 4 5 3
    C0 C1 C2 C3 C4
    we have So as (P0,C0) and (P4,C0)
    assuming that the one with the smaller index has lesser weight PO is selected.In the program I have used random weights.from set S1 we select the pair PO,CO
    S1 =(P0,C1),(P1,C1) and (P4,C1)
    since P0 and P4 are already used in previous set we dont use them for checking in S1 so we have (P1,C1) as best.
    S2=(P0,C2),(P1,C2) and (P4,C2) so we dont use P0,C2 and P1 and C2 because PO and P1 are already used in S1.
    So we choose P4,C2
    in S3 and S4 ae have (P0,C3),(P1,C3),(P4,C3) so we dont choose anything
    and same in S4 also.
    So answer is
    (P0,C0),(P1,C1) and (P4,C2).
    My program is trying to assign weights and I am trying to print the weights along with the sets.It doesnt work fine.I need help to write this program to do this.
    Thanks.
    Regards.
    NP
    What I have tried till now.
    I have one more question could you help me with this.
    I have an array list of this form.
    package mypackage1;
    import java.util.*;
    public class DD
    private  int P;
    private  int C;
    private int weight;
    public void set_p(int P1)
    P=P1;
    public void set_c(int C1)
    C=C1;
    public void set_weight(int W1)
    weight=W1;
    public int get_p()
    return P;
    public int get_c()
    return C;
    public int get_x()
    return weight;
    public static void main(String args[])
    ArrayList a=new ArrayList();
    ArrayList min_weights_int=new ArrayList();
    ArrayList rows=new ArrayList();
    ArrayList temp=new ArrayList();
    Hashtable h=new Hashtable();
    String v;
    int o=0;
    DD[] d=new DD[5];
    for(int i=0;i<4;i++)
    d=new DD();
    for(int i=0;i<4;i++)
    d[i].set_p(((int)(StrictMath.random()*10 + 1)));
    d[i].set_c((int)(StrictMath.random()*10 + 1));
    d[i].set_weight(0);
    System.out.println("Producers");
    for(int i=0;i<4;i++)
    System.out.println(d[i].get_p());
    System.out.println("Consumers");
    for(int i=0;i<4;i++)
    System.out.println(d[i].get_c());
    System.out.println("Weights");
    for(int i=0;i<4;i++)
    System.out.println(d[i].get_x());
    for(int i=0;i<4;i++ )
    int bi =d[i].get_c();
    ArrayList row=new ArrayList();
    for(int j=0;j<4;j++)
    if( d[j].get_p() >=bi)
    d[j].set_weight((int)(StrictMath.random()*10 + 1));
    row.add("(" + bi + "," + d[j].get_p() + "," +d[j].get_x() + ")");
    else
    d[j].set_weight(0);
    row.add("null");
    rows.add(row);
    System.out.println(rows);
    int f=0;
    for(Iterator p=rows.iterator();p.hasNext();)
    temp=(ArrayList)p.next();
    String S="S" +f;
    h.put(S,temp);
    String tt=new String();
    for(int j=0;j<4;j++)
    if(temp.get(j).toString() !="null")
    // System.out.println("In if loop");
    //System.out.println(temp.get(j).toString());
    String l=temp.get(j).toString();
    System.out.println(l);
    //System.out.println("Comma matches" + l.lastIndexOf(","));
    //System.out.println(min_weights);
    f++;
    for(Enumeration e=h.keys();e.hasMoreElements();)
    //System.out.println("I am here");
    int ii=0;
    int smallest=0;
    String key=(String)e.nextElement();
    System.out.println("key=" + key);
    temp=(ArrayList)h.get(key);
    System.out.println("Array List" + temp);
    for( int j=0;j<4;j++)
    String l=(temp.get(j).toString());
    if(l!="null")
    System.out.println("l=" +l);
    [\code]

    In your example you selected the pair with the greatest
    distance from the first set, and the pair with the least
    distance from the second. I don't see how the distance
    function was used.
    Also it's not clear to me that there is always a solution,
    and, if there is, whether consistently choosing the
    furthest or the closest pairs will always work.
    The most obvious approach is to systematically try
    all possibilities until the answer is reached, or there
    are no possibilities left. This means backtracking whenever
    a point is reached where you cannot continue. In this case
    backtrack one step and try another possibility at this
    step. After all possible choices of the previous step,
    backtrack one more step and so on.
    This seems rather involved, and it probably is.
    Interestingly, if you know Prolog, it is ridiculously
    easy because Prolog does all the backtracking for you.
    In Java, you can implement the algorithm in much the same
    way as Prolog implementations do it--keep a list of all the
    choice points and work through them until success or there
    are none left.
    If you do know Prolog, you could generate lots of random
    problems and see if there is always a solution.

  • Zen Vision:M problem, NEED HELP!

    My zen vision:m is starting to run slowly. It started right after my player froze and i reset it.Now its really slow and barely even switches screens sometimes.Right now its just a black screen with the keypad lit up.Whats wrong with it'sI NEED HELP!

    johnnnyp wrote:
    hi, i have a problem with my creative vision m. i wanted to watch a movie and it froze. i tried to shut it down but it wouldnt respond, and now is frozen. please help me if you can!
    You know its kinda rude to derail XBenzinoFla thread with your own problems, make your own thread next time.
    But to the both of you especially XBenzinoFla, try putting your ZVM in rescue mode and run scan disk to see if it hel
    ps.

  • Zen Micro problem need help

    Today i was listening to music and my zen micro just froze while playing and no buttons could be pressed and the lock button wasnt on. So i took the battery out and rebooted the player but it froze at the creative screen. I went home and i went to recovery mode and tried to reload the firmware but it said erasing firmware for more than 2 hours. So then i tried a format but it said formating for the same amount of time. I need help please. Also, recently i've had problems witht the headphone jack. When ever i would stick it in it would sound distorted and i would have to move it around until i got it to a certain spot to hear it good again. If anyone else has this problem please tell me. One more thing i had returned my other micro zen in for hard dri've probems and this was my new one do u think if i have to return in (hopefully not) that they would accept it.

    If the functions in Rescue Mode aren't working properly then you need to contact Creative Support.

  • Ipod problem NEED HELP ASAP

    Hello guys,my ipod touch has battery problems and internal speaker are not working and will apple replace me a new one,i even have 1 year warranty and i want a new ipod touch white instead of black<<<plz plz plz reply ASAP plz really need HELP!THANK YOU

    If you iPod is defective, in warranty and not abused Apple will replace it with a refurbished one.  They may or may not replace it with the white one.  You will have to ask.
    Other users have asked the same question but I hav never heard them come back with whether or not they go the color changed.

  • Urgent Problem, need help asap.

    Hello everyone,
    I'm sorry for the alarmist title, but I need help and I need it badly. Just last night, my macbook froze with nothing working. The mouse froze, the interrupt keys didn't work, nothing. I shut down the laptop, and tried to restart. I noticed a clicking sound coming from the lower left hand corner of the macbook. I'm assuming this is the hard drive.
    What happens is that there will be two clicks happening in a rythmic fashion, and after 15 second of booting up, a folder will appear with a question mark on the screen. The only thing I can do is power it down. Can someone please describe what is happening and make suggestions?
    The kicker is that I'm a college student studying in Denmark for the semester. The laptop is my only lifeline to back home. Please, any help is greatly appreciated.
    Matt

    You may have a disk failure or simply corrupted files. If you have a bootable backup that is working, then you can boot from it, erase your hard drive, then restore your backup. If not then do this:
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger and Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior (4.0 for Tiger, and 4.1 for Leopard) and/or TechTool Pro (4.6.1 for Leopard) to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    If the drive is OK then you can reinstall OS X:
    How to Perform an Archive and Install
    An Archive and Install will NOT erase your hard drive, but you must have sufficient free space for a second OS X installation which could be from 3-9 GBs depending upon the version of OS X and selected installation options. The free space requirement is over and above normal free space requirements which should be at least 6-10 GBs. Read all the linked references carefully before proceeding.
    1. Be sure to use Disk Utility first to repair the disk before performing the Archive and Install.
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior (4.0 for Tiger) and/or TechTool Pro (4.5.2 for Tiger) to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Do not proceed with an Archive and Install if DU reports errors it cannot fix. In that case use Disk Warrior and/or TechTool Pro to repair the hard drive. If neither can repair the drive, then you will have to erase the drive and reinstall from scratch.
    3. Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When you reach the screen to select a destination drive click once on the destination drive then click on the Option button. Select the Archive and Install option. You have an option to preserve users and network preferences. Only select this option if you are sure you have no corrupted files in your user accounts. Otherwise leave this option unchecked. Click on the OK button and continue with the OS X Installation.
    4. Upon completion of the Archive and Install you will have a Previous System Folder in the root directory. You should retain the PSF until you are sure you do not need to manually transfer any items from the PSF to your newly installed system.
    5. After moving any items you want to keep from the PSF you should delete it. You can back it up if you prefer, but you must delete it from the hard drive.
    6. You can now download a Combo Updater directly from Apple's download site to update your new system to the desired version as well as install any security or other updates. You can also do this using Software Update.

  • Need help with method... wrote an addition program... have most of it

    Writing an addition program... have most of it below. Need help in getting the program to work.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Ch10program2 extends JFrame implements ActionListener
    private static final int FRAME_WIDTH = 750;
    private static final int FRAME_HEIGHT = 150;
    private static final int BUTTON_HEIGHT = 50;
    private static final int BUTTON_WIDTH = 50;
    private static final int BUTTON_Y_POSITION = 50;
    private static final String EMPTY_STRING = "";
    private int XbuttonPosition = 15;
    private JButton[] button;
    private String[] buttonLabels = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "=", "c"};
    private JTextField mytextfield;
    private int[] numberOne;
    private int[] numberTwo;
    private int[] sum;
    private int numberCounter = 0;
    private boolean adding = false;
    public static void main (String[] args)
    Ch10program2 frame = new Ch10program2 ();
    frame.setVisible (true);
    public Ch10program2 ()
    Container contentPane = getContentPane ();
    // set the frame properties
    setSize (FRAME_WIDTH, FRAME_HEIGHT);
    setLocation (200, 200);
    setTitle ("Big Integer Adder");
    setResizable (false);
    //set the content pane properties
    contentPane.setLayout (null);
    //creating each button
    button = new JButton [13];
    for (int i = 0 ; i < button.length ; i++)
    button = new JButton (buttonLabels [i]);
    button [i].setBounds (XbuttonPosition, BUTTON_Y_POSITION, BUTTON_WIDTH, BUTTON_HEIGHT);
    XbuttonPosition += 55;
    button [i].setForeground (Color.blue);
    if (i > 9)
    button [i].setForeground (Color.red);
    contentPane.add (button [i]);
    button [i].addActionListener (this);
    //set the arrays
    numberOne = new int [50];
    numberTwo = new int [50];
    //set the needed textfield
    mytextfield = new JTextField ("");
    mytextfield.setBounds (10, 10, 720, 25);
    mytextfield.setBorder (BorderFactory.createLoweredBevelBorder ());
    mytextfield.setHorizontalAlignment (JTextField.RIGHT);
    contentPane.add (mytextfield);
    setDefaultCloseOperation (EXIT_ON_CLOSE);
    public void actionPerformed (ActionEvent event)
    JButton clickedButton = (JButton) event.getSource ();
    String oldText = mytextfield.getText ();
    if ((event.getActionCommand ()).equals ("+"))
    mytextfield.setText (oldText + " + ");
    adding = true;
    numberCounter = 0;
    else if ((event.getActionCommand ()).equals ("="))
    mytextfield.setText (oldText + " = ");
    addArrays ();
    displayArray ();
    else if ((event.getActionCommand ()).equals ("c"))
    clearText ();
    else if (adding == false)
    mytextfield.setText (oldText + event.getActionCommand ());
    if (numberCounter == 0)
    numberOne [numberCounter] = Integer.parseInt (event.getActionCommand ());
    else
    for (int i = numberOne.length - 1 ; i > 0 ; i--)
    numberOne [i] = numberOne [i - 1];
    numberOne [0] = Integer.parseInt (event.getActionCommand ());
    numberCounter++;
    else
    mytextfield.setText (oldText + event.getActionCommand ());
    if (numberCounter == 0)
    numberTwo [numberCounter] = Integer.parseInt (event.getActionCommand ());
    else
    for (int i = numberTwo.length - 1 ; i > 0 ; i--)
    numberTwo [i] = numberTwo [i - 1];
    numberTwo [0] = Integer.parseInt (event.getActionCommand ());
    numberCounter++;
    oldText = mytextfield.getText ();
    public void addArrays ()
    int temp = 0;
    int carriedDigit = 0;
    for (int i = 0 ; i < 50 ; i++)
    temp = carriedDigit + numberOne [i] + numberTwo [i];
    if (temp > 10)
    sum [i] = (temp - 10);
    carriedDigit = 1;
    else
    sum [i] = temp;
    public void displayArray ()
    private void clearText ()
    mytextfield.setText (EMPTY_STRING);

    I don't know what you want to do
    but i have taken your program to get the GUI then the logic is your's
    You try solving it.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Ch10program2 extends JFrame implements ActionListener
    private static final int FRAME_WIDTH = 750;
    private static final int FRAME_HEIGHT = 150;
    private static final int BUTTON_HEIGHT = 50;
    private static final int BUTTON_WIDTH = 50;
    private static final int BUTTON_Y_POSITION = 50;
    private static final String EMPTY_STRING = "";
    private int XbuttonPosition = 15;
    private JButton[] button;
    private String[] buttonLabels = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "=", "c"};
    private JTextField mytextfield;
    private int[] numberOne;
    private int[] numberTwo;
    private int[] sum;
    private int numberCounter = 0;
    private boolean adding = false;
    public static void main (String[] args)
    Ch10program2 frame = new Ch10program2 ();
    frame.setVisible (true);
    public Ch10program2 ()
    Container contentPane = getContentPane ();
    // set the frame properties
    setSize (FRAME_WIDTH, FRAME_HEIGHT);
    setLocation (200, 200);
    setTitle ("Big Integer Adder");
    setResizable (false);
    //set the content pane properties
    contentPane.setLayout (null);
    //creating each button
    button = new JButton [13];
    for (int i = 0 ; i < button.length ; i++)
    button[i] = new JButton (buttonLabels);
    button[i].setBounds (XbuttonPosition, BUTTON_Y_POSITION, BUTTON_WIDTH, BUTTON_HEIGHT);
    XbuttonPosition += 55;
    button[i].setForeground (Color.blue);
    if (i > 9)
    button[i].setForeground (Color.red);
    contentPane.add (button[i]);
    button[i].addActionListener (this);
    //set the arrays
    numberOne = new int [50];
    numberTwo = new int [50];
    //set the needed textfield
    mytextfield = new JTextField ("");
    mytextfield.setBounds (10, 10, 720, 25);
    mytextfield.setBorder (BorderFactory.createLoweredBevelBorder ());
    mytextfield.setHorizontalAlignment (JTextField.RIGHT);
    contentPane.add (mytextfield);
    setDefaultCloseOperation (EXIT_ON_CLOSE);
    public void actionPerformed (ActionEvent event)
    JButton clickedButton = (JButton) event.getSource ();
    String oldText = mytextfield.getText ();
    if ((event.getActionCommand ()).equals ("+"))
    mytextfield.setText (oldText + " + ");
    adding = true;
    numberCounter = 0;
    else if ((event.getActionCommand ()).equals ("="))
    mytextfield.setText (oldText + " = ");
    addArrays ();
    displayArray ();
    else if ((event.getActionCommand ()).equals ("c"))
    clearText ();
    else if (adding == false)
    mytextfield.setText (oldText + event.getActionCommand ());
    if (numberCounter == 0)
    numberOne [numberCounter] = Integer.parseInt (event.getActionCommand ());
    else
    for (int i = numberOne.length - 1 ; i > 0 ; i--)
    numberOne[i] = numberOne [i - 1];
    numberOne [0] = Integer.parseInt (event.getActionCommand ());
    numberCounter++;
    else
    mytextfield.setText (oldText + event.getActionCommand ());
    if (numberCounter == 0)
    numberTwo [numberCounter] = Integer.parseInt (event.getActionCommand ());
    else
    for (int i = numberTwo.length - 1 ; i > 0 ; i--)
    numberTwo[i] = numberTwo [i - 1];
    numberTwo [0] = Integer.parseInt (event.getActionCommand ());
    numberCounter++;
    oldText = mytextfield.getText ();
    public void addArrays ()
    int temp = 0;
    int carriedDigit = 0;
    for (int i = 0 ; i < 50 ; i++)
    temp = carriedDigit + numberOne[i] + numberTwo[i] ;
    if (temp > 10)
    sum[i] = (temp - 10);
    carriedDigit = 1;
    else
    sum[i] = temp;
    public void displayArray ()
    private void clearText ()
    mytextfield.setText (EMPTY_STRING);
    All The Best

Maybe you are looking for