Making a simple calc applet.  Where am I going wrong?

Hi everyone. I'm taking a introductory java class over the summer and so far I've been doing pretty good in it. I've been able to knock out and figure out how to do most of the assignments on my own. But this latest problem is driving me up a wall. I think I might be making it more difficult then it is. I'm supposed to a take a simple calculation program, and then convert it into an applet with new button functionality and text fields. In the applet, there will be two text fields(input and result) and two buttons(Update and Reset). In the first field you put in an operator and a number. Then from there you hit the Update button and the new value is put in the second field.
For example. The program is defaulted to "0". So you put "+ 9" in the first field, then Hit Update. "9" will now appear in the second field. Go back to the first field and put in "- 3", hit update again and now the second field will go to "6." You can keep doing this all you want. Then when you want to start all over again you hit reset. Its sort of a weird program.
Here's the original calc program:
import java.util.Scanner;
Simple line-oriented calculator program. The class
can also be used to create other calculator programs.
public class Calculator
    private double result;
    private double precision = 0.0001; // Numbers this close to zero are
                                       // treated as if equal to zero.
    public static void main(String[] args)
        Calculator clerk = new Calculator( );
        try
            System.out.println("Calculator is on.");
            System.out.print("Format of each line: ");
            System.out.println("operator space number");
            System.out.println("For example: + 3");
            System.out.println("To end, enter the letter e.");
            clerk.doCalculation();
        catch(UnknownOpException e)
            clerk.handleUnknownOpException(e);
        catch(DivideByZeroException e)
            clerk.handleDivideByZeroException(e);
        System.out.println("The final result is " +
                                  clerk.getResult( ));
        System.out.println("Calculator program ending.");
    public Calculator( )
        result = 0;
    public void reset( )
        result = 0;
    public void setResult(double newResult)
        result = newResult;
    public double getResult( )
        return result;
     The heart of a calculator. This does not give
     instructions. Input errors throw exceptions.
    public void doCalculation( ) throws DivideByZeroException,
                                        UnknownOpException
        Scanner keyboard = new Scanner(System.in);
        boolean done = false;
        result = 0;
        System.out.println("result = " + result);
        while (!done)
           char nextOp = (keyboard.next( )).charAt(0);
            if ((nextOp == 'e') || (nextOp == 'E'))
                done = true;
            else
                double nextNumber = keyboard.nextDouble( );
                result = evaluate(nextOp, result, nextNumber);
                System.out.println("result " + nextOp + " " +
                                   nextNumber + " = " + result);
                System.out.println("updated result = " + result);
     Returns n1 op n2, provided op is one of '+', '-', '*',or '/'.
     Any other value of op throws UnknownOpException.
    public double evaluate(char op, double n1, double n2)
                  throws DivideByZeroException, UnknownOpException
        double answer;
        switch (op)
            case '+':
                answer = n1 + n2;
                break;
            case '-':
                answer = n1 - n2;
                break;
            case '*':
                answer = n1 * n2;
                break;
            case '/':
                if ((-precision < n2) && (n2 < precision))
                    throw new DivideByZeroException( );
                answer = n1 / n2;
                break;
            default:
                throw new UnknownOpException(op);
        return answer;
    public void handleDivideByZeroException(DivideByZeroException e)
        System.out.println("Dividing by zero.");
        System.out.println("Program aborted");
        System.exit(0);
    public void handleUnknownOpException(UnknownOpException e)
        System.out.println(e.getMessage( ));
        System.out.println("Try again from the beginning:");
        try
            System.out.print("Format of each line: ");
            System.out.println("operator number");
            System.out.println("For example: + 3");
            System.out.println("To end, enter the letter e.");
            doCalculation( );
        catch(UnknownOpException e2)
            System.out.println(e2.getMessage( ));
            System.out.println("Try again at some other time.");
            System.out.println("Program ending.");
            System.exit(0);
        catch(DivideByZeroException e3)
            handleDivideByZeroException(e3);
}Here's me trying to make it into an applet with the added button functionality.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.math.*;
import java.util.*;
import java.io.*;
import java.lang.*;
public class Calculator extends JApplet implements ActionListener
          // Variables declaration. 
           private javax.swing.JPanel jPanel2;
         private javax.swing.JLabel jLabel2;
         private javax.swing.JTextField jTextField1;
         private javax.swing.JLabel jLabel3;
         private javax.swing.JTextField jTextField2;
         private javax.swing.JButton jButton1;
         private javax.swing.JButton jButton2;
         private javax.swing.JTextArea resultArea;
         private Container container;
         // End of variables declaration
     public void init () {
        initComponents();    
        setSize(400, 200);       
    private void initComponents() {
        container = getContentPane();
        container.setLayout( new BorderLayout() );
            // Creating instances of each item 
            jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        resultArea = new javax.swing.JTextArea();
            // End Creation
        // Set text on labels, preferred size can be optional on labels,
            // size should/must be used on text fields.
          // Then each individual item is added to a panel.
        jLabel2.setText("Input =");
        jPanel2.add(jLabel2);
        jTextField1.setText("");
        jTextField1.setPreferredSize(new java.awt.Dimension(65, 20));
        jPanel2.add(jTextField1);
        container.add( jPanel2, BorderLayout.SOUTH);
        jButton1.setText("Update");
            jButton1.addActionListener(this);
            jButton2.setText("Reset");
            jButton2.addActionListener(this);
            container.add(resultArea, BorderLayout.CENTER);
        container.add(jButton1, BorderLayout.WEST);
        container.add(jButton2, BorderLayout.EAST);
                 resultArea.setText("Calculator is on.\n" +
                         "Format of each line: " +
                                         "\noperator space number" +
                         "\nFor example: + 3" +
                                         "\nThen hit Update to compute"+
                         "\nHit Reset to set the result back to zero.");
   private double result;
   private double precision = 0.0001;
   public void actionPerformed(ActionEvent e)
            Calculator clerk = new Calculator( );
        try
            clerk.doCalculation();
            catch(UnknownOpException e2)
            clerk.handleUnknownOpException(e2);
        catch(DivideByZeroException e2)
            clerk.handleDivideByZeroException(e2);
        resultArea.setText("The final result is " + clerk.getResult( )+
                                    "\nCalculator program ending.");
     public Calculator( )
        result = 0;
    public void reset( )
        result = 0;
    public void setResult(double newResult)
        result = newResult;
    public double getResult( )
        return result;
     The heart of a calculator. This does not give
     instructions. Input errors throw exceptions.
    public void doCalculation( ) throws DivideByZeroException,
                                        UnknownOpException
        Scanner keyboard = new Scanner(System.in);
        boolean done = false;
        result = 0;
        resultArea.setText("result = " + result);
        while (!done)
           char nextOp = (keyboard.next( )).charAt(0);
            if ((nextOp == 'e') || (nextOp == 'E'))
                done = true;
            else
                double nextNumber = keyboard.nextDouble( );
                result = evaluate(nextOp, result, nextNumber);
                resultArea.setText("result " + nextOp + " " + nextNumber + " = " + result+
                                                "\nupdated result = " + result);
     Returns n1 op n2, provided op is one of '+', '-', '*',or '/'.
     Any other value of op throws UnknownOpException.
    public double evaluate(char op, double n1, double n2)
                  throws DivideByZeroException, UnknownOpException
        double answer;
        switch (op)
            case '+':
                answer = n1 + n2;
                break;
            case '-':
                answer = n1 - n2;
                break;
            case '*':
                answer = n1 * n2;
                break;
            case '/':
                if ((-precision < n2) && (n2 < precision))
                    throw new DivideByZeroException( );
                answer = n1 / n2;
                break;
            default:
                throw new UnknownOpException(op);
        return answer;
    public void handleDivideByZeroException(DivideByZeroException e)
        resultArea.setText("Dividing by zero."+
                           "\nProgram aborted");
        System.exit(0);
    public void handleUnknownOpException(UnknownOpException e)
        resultArea.setText(e.getMessage( )+
                          "\nTry again from the beginning:");
        try
            resultArea.setText("Calculator is on.\n" +
                         "Format of each line: " +
                                         "\noperator space number" +
                         "\nFor example: + 3" +
                         "\nHit Reset to set the result back to zero.");
                    doCalculation( );
        catch(UnknownOpException e2)
            System.out.println(e2.getMessage( ));
            System.out.println("Try again at some other time.");
            System.out.println("Program ending.");
            System.exit(0);
        catch(DivideByZeroException e3)
            handleDivideByZeroException(e3);
}I'm not getting any compiling errors or anything and it launches, but it doesn't work at all. I'm sure it has something to do with the calc program and the applet actionevent. I just don't know where to go from there. Can anyone tell me where I'm going wrong? Or even make sense of what I've posted. I know its a lot. I've been looking at this thing for a day now and its killing me. Any help would be greatly appreciated. Thanks.

This is a mistake
public void actionPerformed(ActionEvent e)
            Calculator clerk = new Calculator( );
        try
            clerk.doCalculation();You don't want to create a whole new applet every time anyone pushes a button.
Make whatever changes are neccessary so that you don't have to create a new applet in your actionPerformed

Similar Messages

  • I have an iPhone 4 and an iPod 4th gen linked to the same email address and apple ID. I am trying to set up a new email address for the iPod so a family member can use it but it doesn't want to recognize the new email account. Where am I going wrong?

    I have an iPhone 4 and a 4th gen iPod linked to the same email address and apple ID. I am trying to change the email address on the iPod so a family member can use it but when I do it says it doesn't recognize the email address. Where am I going wrong ? I just want them to be able to iMessage and email without having to use my email address.

    The procedure is Settings>Messages>Send & Receive at>You can be reached by iMessages at>Add another email address. The email address has to be a valid working email address, obviously. Apple should verify the email address and you have to go to the inbox of that email account, read the verification email from Apple and follow the inductions in the email in order to complete the verification. Then you go back to the settings, uncheck your email address and check the new email address to be used as the contact email address.

  • I am contemplating replacing my old Ipod with a 8gb touch which supposedly holds up to 1760 songs. In my ITunes library the average size of a 12 song album is 300mb which means I can get 27 albums x 12 songs is 324 songs. Where am I going wrong here?

    I am contemplating replacing my old Ipod with a 8gb touch which supposedly holds up to 1760 songs. In my ITunes library the average size of a 12 song album is 300mb which means I can get 27 albums x 12 songs is 324 songs. Where am I going wrong here?

    There is about 6.9  GBs of free space on an 8 GB Touch for data storage. That translates to roughly 23 of your average albums.
    Holds up to 1760 songs is based on the size of an average track which is about 3 to 4 MBs, whereas your albums have tracks averaging more like 25 MBs per track. I sort of doubt your average album holds what would be about 5 hours.

  • Can't see where I am going wrong!

    Can anyone see where I am going wrong.....I can't see the problem:
    import java.io.*;
    public class EmployeeRecord {
        private String employeeName;
        private int employeeIDNumber;
        private String jobCat;
        private double hourlyPayRate;
        private double annualSalary;
       /* public constructor.
       public Student(String employeeName, int employeeIDNumber, String jobCat, double hourlyPayRate)
             this.employeeName = employeeName;
             this.employeeIDNumber = employeeIDNumber;
             this.jobCat = jobCat;
             this.hourlyPayRate = hourlyPayRate;
       } // end method
           * return  employee name
          public String getEmployeeName() {
             return employeeName;
          } // end method
           * return employee ID number
          public int getEmployeeIDNumber() {
             return employeeIDNumber;
       } // end method
           * return job Cat
          public String getJobCat() {
             return jobCat;
          } // end method
           * return hourly pay rate
          public double getHourlyPayRate() {
             return hourlyPayRate;
       } // end method
           * return annual salary
          public double getAnnualSalary() {
             return annualSalary;
       } // end method
              public void calculateAnnualSalary(){
                      int tempCount = numberOfScores;
                      int tempScore = totalScore;
                      if (employeeArray[2] == "Full") {
                         annualSalary = 40 * employeeArray[3];
                      else {
                         annualSalary = 20 * employeeArray[3];
                      } // end else
                   } // end method
       public static void main(String[] args) {
          Employee[] employeeArray = { new Employee("JohnSmith", 654789345, "Full", 25.60);
                                        new Employee("BobJones", 456983209, "Full", 28.20);
                                        new Employee("LarryAnders", 989876123, "Full", 35.30);
                                        new Employee("TomEstes", 237847360, "Full", 41.35);
                                           new Employee("MariaCosta", 115387243, "Part", 15.40);
                                           new Employee("JoeShowen", 223456732, "Full", 45.75);
                                           new Employee("JillRoberts", 574839280, "Part", 38.45);
                                           new Employee("MaryAble", 427836410, "Part", 25.90);
                                           new Employee("NancyAtkins", 349856232, "Full", 35.60);
                                           new Employee("MarkSeimens", 328978455, "Full", 48.50);
       } // end method
    } // end classDesign the Java class to represent an employee record. Pseudo code for this object is given below:
    Employee class definition
    Instance Variables
    Employee name
    Employee ID number
    Job category
    Hourly pay rate
    Annual salary
    Instance Methods
    getName
    getEmployeeId
    calculateAnnualSalary
    getAnnualSalary
    Use the String class for the employee name.
    Use an array of objects for the employee records.
    Calculate each employee's annual salary from the job category and hourly rate, using the following constant information:
    Job category: Full - 40 hours a week
    Part - 20 hours a week
    Assume 52 weeks in a year.
    Display each employee's name, id and annual salary.
    Calculate and display the company's total amount for employees salaries.
    Use the following information to populate the employee objects: Employee
    Name Employee Id Job Category Hourly Pay Rate
    John Smith 654789345 Full 25.60
    Bob Jones 456983209 Full 28.20
    Larry Anders 989876123 Full 35.30
    Tom Estes 237847360 Full 41.35
    Maria Costa 115387243 Part 15.40
    Joe Showen 223456732 Full 45.75
    Jill Roberts 574839280 Part 38.45
    Mary Able 427836410 Part 25.90
    Nancy Atkins 349856232 Full 35.60
    Mark Seimens 328978455 Full 48.50

    I think this is what people mean, but It still wont work. Can someone else figure it out?
    import java.io.*;
    public class EmployeeRecord {
    private String employeeName;
    private int employeeIDNumber;
    private String jobCat;
    private double hourlyPayRate;
    private double annualSalary;
    /* public constructor.
    public void EmployeeRecord (String employeeName, int employeeIDNumber, String jobCat, double hourlyPayRate)
    this.employeeName = employeeName;
    this.employeeIDNumber = employeeIDNumber;
    this.jobCat = jobCat;
    this.hourlyPayRate = hourlyPayRate;
    } // end method
    * return employee name
    public String getEmployeeName() {
    return employeeName;
    } // end method
    * return employee ID number
    public int getEmployeeIDNumber() {
    return employeeIDNumber;
    } // end method
    * return job Cat
    public String getJobCat() {
    return jobCat;
    } // end method
    * return hourly pay rate
    public double getHourlyPayRate() {
    return hourlyPayRate;
    } // end method
    * return annual salary
    public double getAnnualSalary() {
    return annualSalary;
    } // end method
         public void calculateAnnualSalary(){
              int tempCount = numberOfScores;
              int tempScore = totalScore;
              if (employeeArray[2] == "Full") {
              annualSalary = 40 * employeeArray[3];
              else {
              annualSalary = 20 * employeeArray[3];
              } // end else
              } // end method
    public static void main(String[] args) {
    EmployeeRecord[] employeeArray = { new EmployeeRecord("JohnSmith", 654789345, "Full", 25.60),
         new EmployeeRecord("BobJones", 456983209, "Full", 28.20),
         new EmployeeRecord("LarryAnders", 989876123, "Full", 35.30),
         new EmployeeRecord("TomEstes", 237847360, "Full", 41.35),
         new EmployeeRecord("MariaCosta", 115387243, "Part", 15.40),
         new EmployeeRecord("JoeShowen", 223456732, "Full", 45.75),
         new EmployeeRecord("JillRoberts", 574839280, "Part", 38.45),
         new EEmployeeRecord("MaryAble", 427836410, "Part", 25.90),
         new EmployeeRecord("NancyAtkins", 349856232, "Full", 35.60),
         new EmployeeRecord("MarkSeimens", 328978455, "Full", 48.50),
    } // end method
    } // end class

  • TS4036 my iphone says i have backed up to icloud but it hasn't, where am i going wrong

    my iphone says i have backed up to icloud but it hasn't, where am i going wrong?

    Troubleshooting Creating Backups

  • TS1367 My Blueyonder email is coming in but won't send, where am I going wrong with the settings?

    My Blueyonder email is coming in but won't send, where am I going wrong with the settings?

    We don't know. You didn't tell us what those settings are. However, if you contact your email provider, Blueyonder, they should be able to help you. Check their website where they may even have information on how to configure Mail for their site.

  • I've just started using the App Tabs. I think this feature could be handy but why are the sites not updated when I start Firefox. Now I have to manually update the site which is somewhat of a downer. Does any of you know where I'm going wrong?

    I've just started using the App Tabs. I think this feature could be handy but why are the sites not updated when I start Firefox. Now I have to manually update the site which is somewhat of a downer. Does any of you know where I'm going wrong?

    To answer the post title FireFox save all downloads automatically in the download folder, which you can find in the Documents folder. If you want to choose where to save your downloads go to tools>options>check always ask me where to save files.
    Secondly, I am assuming you have IE 8 installed as this is the only version that supports this fix that is currently not in beta. Go to control panel>internet options>advanced tab and reset the settings at the bottom. This may or may not fix the problem but it is a good first step.

  • [SOLVED] not sure where i'm going wrong with broadcom-wl drivers...

    so I have this really old laptop (hp dv2310 I think is the exact number) that I thought would be cool to throw arch on.
    Which of course, it is.
    the problem of course is the awful freakin' driver the broadcom wireless card needs. Let me preface by saying I'm somewhat new to linux
    ok, so, I found this post http://zeroincrement.wordpress.com/2009 … -linux-os/ and followed the directions to the end. it seemed like a good solution considering that was the driver that https://wiki.archlinux.org/index.php/Broadcom_wireless said I needed.
    But after I insmod wl.ko and blacklisted b43 and ssb (as per a notice I found after I makepkg) my wlan0 dissapeared from iwconfig..
    /FACEPALM
    Does anyone have experience with this card? please help me out. this whole thing is really getting me down lol. honestly I don't know where to go from here. I was already waaay over my head as it was lol, but it's a laptop...I can't be tethered down to a desk...i'd rather use my desktop.
    Last edited by hypn0tic (2011-04-16 20:37:26)

    Sorry, I was not clear.  You have version 14 which is greater than 13, so you should be good to go.
    Now, just:
    change to a working directory of your choice.  Then:
    wget http://aur.archlinux.org/packages/b43-firmware/b43-firmware.tar.gz
    tar -xvf b43-firmware.tar.gz
    cd b43-firmware
    makepkg
    sudo pacman -U b43-firmware-4.178.10.4-1-x86_64.pkg.tar.xz
    Here is how it looks on my system.  Of course, you will answer 'y' to the install question instead of my 'n'
    ewaller@odin:~ 1001 %wget http://aur.archlinux.org/packages/b43-firmware/b43-firmware.tar.gz
    --2011-04-16 08:49:35-- http://aur.archlinux.org/packages/b43-firmware/b43-firmware.tar.gz
    Resolving aur.archlinux.org... 208.92.232.29
    Connecting to aur.archlinux.org|208.92.232.29|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 692 [application/x-tgz]
    Saving to: “b43-firmware.tar.gz”
    100%[======================================>] 692 --.-K/s in 0s
    2011-04-16 08:49:35 (33.0 MB/s) - “b43-firmware.tar.gz” saved [692/692]
    ewaller@odin:~ 1002 %tar -xvf b43-firmware.tar.gz
    b43-firmware/
    b43-firmware/PKGBUILD
    ewaller@odin:~ 1003 %cd b43-firmware
    ewaller@odin:~/b43-firmware 1004 %makepkg
    ==> Making package: b43-firmware 4.178.10.4-1 (Sat Apr 16 08:50:03 PDT 2011)
    ==> Checking runtime dependencies...
    ==> Checking buildtime dependencies...
    ==> Retrieving Sources...
    -> Downloading broadcom-wl-4.178.10.4.tar.bz2...
    --2011-04-16 08:50:03-- http://mirror2.openwrt.org/sources/broadcom-wl-4.178.10.4.tar.bz2
    Resolving mirror2.openwrt.org... 46.4.11.11
    Connecting to mirror2.openwrt.org|46.4.11.11|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 5986780 (5.7M) [application/x-bzip2]
    Saving to: “broadcom-wl-4.178.10.4.tar.bz2.part”
    100%[======================================>] 5,986,780 625K/s in 11s
    2011-04-16 08:50:14 (557 KB/s) - “broadcom-wl-4.178.10.4.tar.bz2.part” saved [5986780/5986780]
    ==> Validating source files with sha1sums...
    broadcom-wl-4.178.10.4.tar.bz2 ... Passed
    ==> Extracting Sources...
    -> Extracting broadcom-wl-4.178.10.4.tar.bz2 with bsdtar
    ==> Starting build()...
    ==> Entering fakeroot environment...
    ==> Starting package()...
    This file is recognised as:
    ID : FW15
    filename : wl_apsta.o
    version : 478.104
    MD5 : bb8537e3204a1ea5903fe3e66b5e2763
    Extracting b43/ucode5.fw
    Extracting b43/pcm5.fw
    Extracting b43/b0g0bsinitvals5.fw
    Extracting b43/a0g0bsinitvals5.fw
    Extracting b43/b0g0initvals5.fw
    Extracting b43/a0g1initvals5.fw
    Extracting b43/a0g0initvals5.fw
    Extracting b43/a0g1bsinitvals5.fw
    Extracting b43/ucode9.fw
    Extracting b43/a0g1initvals9.fw
    Extracting b43/a0g0bsinitvals9.fw
    Extracting b43/b0g0bsinitvals9.fw
    Extracting b43/b0g0initvals9.fw
    Extracting b43/a0g1bsinitvals9.fw
    Extracting b43/a0g0initvals9.fw
    Extracting b43/ucode11.fw
    Extracting b43/n0bsinitvals11.fw
    Extracting b43/n0absinitvals11.fw
    Extracting b43/n0initvals11.fw
    Extracting b43/ucode13.fw
    Extracting b43/b0g0initvals13.fw
    Extracting b43/a0g1bsinitvals13.fw
    Extracting b43/a0g1initvals13.fw
    Extracting b43/lp0bsinitvals13.fw
    Extracting b43/b0g0bsinitvals13.fw
    Extracting b43/lp0initvals13.fw
    Extracting b43/ucode14.fw
    Extracting b43/lp0initvals14.fw
    Extracting b43/lp0bsinitvals14.fw
    Extracting b43/ucode15.fw
    Extracting b43/lp0bsinitvals15.fw
    Extracting b43/lp0initvals15.fw
    Extracting b43/ucode16.fw
    Extracting b43/n0bsinitvals16.fw
    Extracting b43/sslpn0initvals16.fw
    Extracting b43/n0initvals16.fw
    Extracting b43/lp0initvals16.fw
    Extracting b43/sslpn0bsinitvals16.fw
    Extracting b43/lp0bsinitvals16.fw
    ==> You should also add 'b43' into the 'modules' section of your '/etc/rc.conf' file.
    ==> Tidying install...
    -> Purging other files...
    -> Compressing man and info pages...
    -> Stripping unneeded symbols from binaries and libraries...
    -> Removing empty directories...
    ==> Creating package...
    -> Generating .PKGINFO file...
    -> Compressing package...
    ==> Leaving fakeroot environment.
    ==> Finished making: b43-firmware 4.178.10.4-1 (Sat Apr 16 08:50:18 PDT 2011)
    ewaller@odin:~/b43-firmware 1005 %pacman -U b43-firmware-4.178.10.4-1-x86_64.pkg.tar.xz
    error: you cannot perform this operation unless you are root.
    ewaller@odin:~/b43-firmware[1] 1006 %sudo pacman -U b43-firmware-4.178.10.4-1-x86_64.pkg.tar.xz
    Password:
    warning: b43-firmware-4.178.10.4-1 is up to date -- reinstalling
    resolving dependencies...
    looking for inter-conflicts...
    Targets (1): b43-firmware-4.178.10.4-1
    Total Download Size: 0.00 MB
    Total Installed Size: 0.36 MB
    Proceed with installation? [Y/n] n
    ewaller@odin:~/b43-firmware 1007 %

  • Can you have a look at my code please, where am i going wrong?

    Compiles fine but i get a nullPointerException
    in the setLayerOne() method and the setInputs() method
    the error seems to point to the Neuron[][] network
    but i thought it should be ok as i initilised the pointer as static
    the Neuron class is compiled and contains both these methods.
    also, is this bad design to make all my varibles static like this
    thanks for the help
    Tim
    import java.io.*;
    public class Guesser {
      static char[] user = new char[100];
      static int guess_no = 1;
      static int noOfLayers;
      static BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
      static Neuron[][] network;
      static int[] layers;
      public static void main(String args[])
        throws IOException
        guesserNetwork();
      ///now for the guessing bit
      int guess_no = 0;
      char guess;
      //char dummy;
      //BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
      char[] user = new char[100];
      while (guess_no<10) {
        System.out.println("Please think of Heads (H) or Tails (T) then press enter.");
        if (guess_no == 1)
          guess = 'H';
        else if ( user[guess_no] == 'H' )
          guess = 'T';
        else
          guess = 'H';
        // now we tell the user what our guess was,
        char dummy;
        dummy = (char) br.read(); // wait for the return key pressed
        System.out.println(guess);
        // Find out what the user was thinking of
        // and force the user to H or T
        user[guess_no] = (char) br.read();
        if (user[guess_no] == 'h')
        {user[guess_no] = 'H';}  //this does not work i dont know why
        else if (user[guess_no] == 't')
        {user[guess_no] = 'T';}
        dummy = (char) br.read(); // clear the stream for the return key press
        while ( user[guess_no] != 'H' && user[guess_no] != 'T')
          System.out.println("You must enter H or T");
          user[guess_no] = (char) br.read();
        setLayerOne();  //////HERES WHERE I GET NULLPOINTER EXCEPTION
        guess_no++;
      while (guess_no<100){
        //call update method
        //print output of last node
        network[0][guess_no].inputGuess(guess_no);
        guess_no++;
      static void setLayerOne() ////I GET NULLPOINTER EXCEPTION
       network[0][guess_no].inputGuess(guess_no); // sets the first layer neurons
      static void setInputs ()
         for (int i = 1; i < noOfLayers; i++){
           for(int j=0; j < layers; j++){
    network[i][j].updateInput(i, network[i-1], network[i-1].length); //sets the other neurons
    static void guesserNetwork()
    int noOfNeurons[] = {10,1,1};
    int nodes = 0;
    noOfLayers = 3;
    int[] layers = new int[noOfLayers];
    for (int i =0; i < noOfLayers; i++)
    layers[i] = noOfNeurons[i];
    System.out.println("layer " + (i + 1) + " has " + noOfNeurons[i] + " neurons");
    nodes += noOfNeurons[i];
    System.out.println("total no of nodes = " + nodes);
    System.out.println("building network...");
    //make (noOfLayers)arrays of arrays
    Neuron[][] network = new Neuron[noOfLayers][];
    for (int i=0; i < noOfLayers; i++)
    //for each layer make the desired number of rows(of neurons)
    int rows = layers[i];
    network[i] = new Neuron[rows];
    //instinate neuron objects one by one
    for (int j=0; j < layers[i]; j++)
    if (i==0)
    network[i][j] = new Neuron(noOfLayers, i, j, rows, 1, user[j]);
    else
    boolean isFirstLayer = false;
    network[i][j] = new Neuron(noOfLayers, i, j, rows, layers[i-1], network[i-1]);

    Main calls guesserNetwork() which initilises the array:-
    Neuron[][] network = new Neuron[noOfLayers][];
         for (int i=0; i < noOfLayers; i++)
           //for each layer make the desired number of rows(of neurons)
           int rows = layers;
    network[i] = new Neuron[rows];
    //instinate neuron objects one by one
    for (int j=0; j < layers[i]; j++)
    if (i==0)
    network[i][j] = new Neuron(noOfLayers, i, j, rows, 1, user[j]);
    else
    boolean isFirstLayer = false;
    network[i][j] = new Neuron(noOfLayers, i, j, rows, layers[i-1], network[i-1]);
    later main calls setLayerOne():-
    static void setLayerOne()
       network[0][guess_no].inputGuess(guess_no); // sets the first layer neurons
      }and gives this error:-
    NullPointerException:
    at Guesser.setLayerOne(Guesser.java:77)
    at Guesser.main(Guesser.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    I nave set network[][] to static so that it can be acessed from the main method and the other methods in this class.
    thanks again

  • I want to download movies to my ipad directly.  The free VLC media says it does not support address. What app should I use or where am I going wrong?

    I want to download movies from Putlocker to my ipad directly on off hours.  I read to get the VLC media (free) app.  I put in the address for Putlocker and it stated that this version did not support this address.  Help!  I am new to this and want an app that is easy, supports Putlocker, set time to download and speed.  Any suggestions?

    To answer the post title FireFox save all downloads automatically in the download folder, which you can find in the Documents folder. If you want to choose where to save your downloads go to tools>options>check always ask me where to save files.
    Secondly, I am assuming you have IE 8 installed as this is the only version that supports this fix that is currently not in beta. Go to control panel>internet options>advanced tab and reset the settings at the bottom. This may or may not fix the problem but it is a good first step.

  • Can Someone See Where I'm Going Wrong???

    I'm trying to digitize footage from my camera and I'm getting this
    Here's my setup:
    The footage was shot in HDV 1080i60.  Is my Capture Preset wrong? Device Control wrong?  What should it be?  I've checked my connections and the camera.  The camera is telling me that it's sending a DVout singnal in HDV10801.  What to do???  Plus FCP controls the deck it just won't "see" the video so that tells me that the firewire is at least talking to from camera to computer.  HELP!!!

    OK, disconnect the camera from the computer. Power everything off.
    Start up the computer, keeping the camera disconnected, and use Digital Rebellion's Preference Manager to reset your FCP preferences. If you have been making lots of changes to the ingest settings, with the camera connected, it is possible you have corrupted your preferences. Preference Manager is free, and you can archive your old preferences if you want to revert to them.
    http://www.digitalrebellion.com/prefman/
    Next, keeping the camera disconnected from the computer, turn it on. Do you have the operator's manual for the camera? You want to look at page 75. If not, here are some highlights:
    So you want to make sure iLink Conv is set to OFF.
    Now that you have set your camera menus, and reset your FCP prefs, shut everything down, connect everything together, and turn everything on.
    When you launch FCP you will need to reset your scratch disk and choose your Easy Setup.
    See if this helps.
    MtD

  • Help! When I try to download music from iCloud onto new iPhone it appears to go through the downloading process but then does not show up on the phone. Where am I going wrong?

    Have gone onto iTunes and selected purchased music. Then clicked on download all... It then appears to be going through the correct process but then music does not store on the phone. What am I doing wrong?

    Nothing you doing wrong, there is just not enough space on your phone.

  • Please tell me where I'm going wrong

    I am in a beginning Java programming class. For my assignment, I was to modify an ATM program to debit an amount. That I've done successfully.
    The program I am having is if the amount is greater than the balance, how can I get a statement to say the balance is over?
    I'm not looking for anyone to do this for me. I want to learn Java myself, but I'm finding an error I don't understand how to fix.
    This is my class.
    public class Account
         private double balance;
         public Account( double initialBalance )
         if ( initialBalance > 0.0 )
         balance = initialBalance;
         public void debit( double amount )
         balance = balance - amount;
         public double getBalance()
         return balance;
         if ( balance < 0 ) // I put this in, this isn't the original code, but it seemed like a good idea
         System.out.printf( "Withdrawal amount exceeded account balance." );
    }This is my test class.
    import java.util.Scanner;
    public class AccountTest
         public static void main( String args[] )
         Account account1 = new Account( 50.00 );
         Account account2 = new Account( -7.53 );
         System.out.printf( "account1 balance: $%.2f\n",
         account1.getBalance() );
         System.out.printf( "account2 balance: $%.2f\n\n",
         account2.getBalance() );
         Scanner input = new Scanner( System.in );
         double withdrawalAmount;
         System.out.print( "Enter withdrawal amount for account1: ");
         withdrawalAmount = input.nextDouble();
         System.out.printf( "\nsubtracting %.2f to account1 balance\n\n",
         withdrawalAmount );
         account1.debit( withdrawalAmount );
         if ( withdrawalAmount > balance )
         System.out.printf( "Withdrawal amount exceeded account balance." );
         System.out.printf( "account1 balance: $%.2f\n",
         account1.getBalance() );
         System.out.printf( "account2 balance: $%.2f\n",
         account2.getBalance() );
         System.out.print( "Enter withdrawal amount for account2: ");
         withdrawalAmount = input.nextDouble();
         System.out.printf( "\nsubtracting %.2f to account2 balance\n\n",
         withdrawalAmount );
         account2.debit( withdrawalAmount );
         System.out.printf( "account1 balance: $%.2f\n",
         account1.getBalance() );
         System.out.printf( "account2 balance: $%.2f\n",
         account2.getBalance() );
         The errors that I'm getting are mostly that the symbol can't be found. The problem I'm having is with this.
    if ( withdrawalAmount > account1Balance )
    System.out.printf( "Withdrawal amount exceeded account balance." );
    How do I define the account balance?
    I appreciate any help. Thanks.

    I'm a bit closer. yeah.
    if ( account1.getBalance() < 0 )
         System.out.printf( "Withdrawal amount exceeded account balance." );I put this gem in my program, I'm getting the warning, but I have to configure it not to subtract past zero.
    import java.util.Scanner;
    public class AccountTest
         public static void main( String args[] )
         Account account1 = new Account( 50.00 );
         Account account2 = new Account( -7.53 );
         System.out.printf( "account1 balance: $%.2f\n",
         account1.getBalance() );
         System.out.printf( "account2 balance: $%.2f\n\n",
         account2.getBalance() );
         Scanner input = new Scanner( System.in );
         double withdrawalAmount;
         System.out.print( "Enter withdrawal amount for account1: ");
         withdrawalAmount = input.nextDouble();
         System.out.printf( "\nsubtracting %.2f to account1 balance\n\n",
         withdrawalAmount );
         account1.debit( withdrawalAmount );
         if ( account1.getBalance() < 0 )
         System.out.printf( "Withdrawal amount exceeded account balance." );
         System.out.printf( "account1 balance: $%.2f\n",
         account1.getBalance() );
         System.out.printf( "account2 balance: $%.2f\n",
         account2.getBalance() );
         System.out.print( "Enter withdrawal amount for account2: ");
         withdrawalAmount = input.nextDouble();
         System.out.printf( "\nsubtracting %.2f to account2 balance\n\n",
         withdrawalAmount );
         account2.debit( withdrawalAmount );
         System.out.printf( "account1 balance: $%.2f\n",
         account1.getBalance() );
         System.out.printf( "account2 balance: $%.2f\n",
         account2.getBalance() );
         

  • Find/Change Grep only finds one instance per paragraph, where am I going wrong?

    Hi,
    I've been using a Find/Change Grep to find any price with a comma and change that comma to a thin space (Newspaper's editorial style).
    But the Grep only finds the first instance of this per paragraph.
    Sample text...
    "$200,000 $200,000 $200,000.
    text at start of paragraph $200,000
    $200,000 text at end of paragraph
    tab     $200,000."
    In the sample the grep would miss the second and third price on the first line.
    I've been using...
    Find...
    (?<=\$)(\d{3})\,?(\d{3})
    also tried (\$\d{3})\,?(\d{3})
    Change to...
    $1~<$2
    Is there anything I can add to find these last two prices?
    I've been using this in combination with Batch Find Replace script, so different greps are set up for 5,6 and 7 digit numbers that start with $.
    Thanks.

    Try this,
    Find what: (?<=\x{0024})(\d{3})\,?(\d{3})
    Change to: $1~<$2
    Vandy

  • Multiple instances: where am i going wrong?

    I'm trying to set up multiple instances of Weblogic5.1 for several
    developers.
    I've completed the following:
    INFO: weblogic home is at D:/weblogic/
    1. I created a developer directory at D:/weblogic/bill/
    2. I made a copy of the weblogic.properties file in the location
    D:/weblogic/bill/weblogic.properties
    3. I edited the copy of weblogic.properties in the following manner:
    - changed weblogic.system.listenPort=7050
    - changed weblogic.password.system=newpass
    - changed weblogic.systems.SSLListenPort=7051
    and also changed items specific to this directory.
    4. In the Global weblogic.properties, I commented out the
    weblogic.system.listenPort, weblogic.password.system and
    weblogic.system.SSLListenPort,
    5. The I copied the default servers startWeblogic.cmd and renamed the copy
    startbill.cmd. I left this at the same location as the default version,
    i.e. D:\weblogic\
    6. Then I edited the startbill.cmd script and added the following to the
    java command line:
    -Dweblogic.home=D:\weblogic\bill\
    -Dweblogic.system.home=D:\weblogic\bill\
    -Dweblogic.system.name=bill
    -Djava.security.manager
    -Djava.security.policy=D:\weblogic\bill\weblogic.policybill
    7. Then I copied the original weblogic.policy file and renamed it
    weblogic.policybill. Then I edited the file and changed the following 2
    lines to:
    grant codeBase "file:D:/weblogic/bill-" {
    permission java.io.FilePermission "D:${/}weblogic${/}bill{/}-",
    Now, when I execute startbill from the command line, I receive the
    following:
    D:\weblogic>-Dweblogic.system.name=D:\weblogic\bill -Djava.security.manager
    -Djava.security.policy=D:\weblogic\bill\weblogic.policybill weblogic.Server
    The name specified is not recognized as an internal or external command,
    operable program or batch file.
    I think I have a path incorrect or something, but my question is am I doing
    this right? Is there a better way? I've read that some people create
    separate instance directories above the weblogic server directory.
    Thanks

    What exactly means "not work"?
    check also
    http://forums.adobe.com/thread/885448
    http://forums.adobe.com/thread/867968

Maybe you are looking for