Please help in calculating average from random nos. generated

Actually i am new to LV and i don't understand e'thing pretty well. Can anyone please help me with this problem?
I have to construct a VI that displays a random no. once every sec., and then in the same VI, i am trying to compute the average of the last four nos. generated, i.e. the average is displayed only after 4 numbers have been generated, else the average displays zero.
Well, i was trying to  get this, but so far what i have got is a VI that is generating average, but that is not what i need.
Thanks for any help.
CL

Easiest would be to use "Mean PtByPt.vi" in the Analyze...Point by Point palette. It is most flexible, e.g. if you would want to change the averaging length in the future.
Alternatively, you could use shift registers initialized with NaN. I would prefer NaN over zero for incomplete samples, zero is not unique, it could be a legal value. See attached simple example (LabVIEW 7.1). Modify as needed.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Average4.vi ‏31 KB

Similar Messages

  • HT201493 How do I get my old apple ID/email from popping up and asking to verifie it's getting annoying? I've change everything to my new email an my old one keeps popping up please help me stop it from popping up all the time?

    How do I get my old apple ID/email from popping up and asking to verifie it's getting annoying? I've change everything to my new email an my old one keeps popping up please help me stop it from popping up all the time?

    Did you change the ID you are using for iCoud?  If so, did you delete the account, then sign back in with your new ID on your device?

  • Please help my ipod disconnected from the Internet and wont reconnect and i did the right password

    please help my ipod disconnected from the Internet and wont reconnect and i did the right password

    - Do other devices still connect to the network?
    - Does the iPod connect to other networks?
    - Reset the iPod. Nothing will be lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on the router.
    - Reset networks settings: Settings>General>Reset>Reset Network Settings
    - iOS: Troubleshooting Wi-Fi networks and connections
    - iOS: Recommended settings for Wi-Fi routers and access points

  • Please help me to convert from 5.0 to 2009

    Please help me to convert from 5.0 to 2009
    Source LabVIEW version: LabView 5.0
    Target LabVIEW Version: LabView 9.0
    Thank you so much..
    Solved!
    Go to Solution.
    Attachments:
    shutter.llb ‏255 KB

    LabVIEW 9.0
    Attachments:
    shutter.llb ‏90 KB

  • My notebook is simply death, so I cannot sync my Ipod with another notebook. What can I do? Please help me! Greetings from Austria

    My main notebook crushes and now I would like to sync my Ipod with annother notebook! So what ca I do? Please help me! Greetings from Austria

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • Please help 'Translate' These codes from AS2 to AS3 for me

    Hi, i need help 'translating' these codes from Action Script 2 to Action Script 3. Please Do it for me:
    toc    loadText = new LoadVars();
        loadText.load("Curie.txt");
        loadText.onLoad = function(success) {
            if (success) {
                // trace(success);
                Curie.html = true;
                Curie.htmlText = this.Curie;
    Please translate it for me, i need it ASAP thanks
    Kenneth

    Thank you for helping me
    Kenneth
    Date: Thu, 15 Oct 2009 05:49:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: Please help 'Translate' These codes from AS2 to AS3 for me
    Take a look at that:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
    There is a LoadVars section on that.
    There is also a tutorial here:
    http://www.republicofcode.com/tutorials/flash/as3externaltext/
    Cheers,
    CaioToOn!
    >

  • PLEASE HELP!!! using servlet to generate an image in jsp page

    Hi,
    I am so stuck on this... please help.
    I have a servlet that generated a gif image dynamically. It uses a bean that stores the gif image in a byte array.
    The servlet outputs the byte data to the output stream. The code is really simple and looks like this:
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //HttpSession session = request.getSession();
            try {
                ServletOutputStream stream = response.getOutputStream();
                ImageByteInformation imageByteInfo = (ImageByteInformation) request.getAttribute("imageByteInformation");
                response.setContentType("image/gif");
                response.setContentLength(imageByteInfo.getByteData().length);
                stream.write(imageByteInfo.getByteData(), 0, imageByteInfo.getByteData().length);
                stream.flush();
            }catch( Exception e){   
                System.out.println("You are hooped!: " + e.getMessage() + " " + e.toString());           
            }When I redirect from the dispatch servlet straight to this servlet an image shows up in the browser window.
    However when I try to use this jsp page to display the image nothing happens...
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h2>Hello World!</h2>
            <img src="servlets/Map24ImageDisplayServlet"/>
             //I also tried src/servlets/Map24..., /src/servlets/Map24..., /display, servlets/display
            <h2>Did you see the image?</h2>
        </body>
    </html>My web.xml is here if it helps...
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <display-name>HelloProject</display-name>
    <servlet>
        <display-name>ServletDispatcher</display-name>
        <servlet-name>ServletDispatcher</servlet-name>
        <servlet-class>servlets.ServletDispatcher</servlet-class>
      </servlet>
      <servlet>
        <display-name>Map24ImageDisplayServlet</display-name>
        <servlet-name>Map24ImageDisplayServlet</servlet-name>
        <servlet-class>servlets.Map24ImageDisplayServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>ServletDispatcher</servlet-name>
        <url-pattern>/hello</url-pattern>
      </servlet-mapping>
      <error-page>
        <error-code>404</error-code>
        <location>/404_error.html</location>
      </error-page>
      <servlet-mapping>
        <servlet-name>Map24ImageDisplayServlet</servlet-name>
        <url-pattern>/display</url-pattern>
      </servlet-mapping>
    </web-app>I can never get an image to come up. In fact I can never get the jsp page to run the servlet at all! HELP!!! What am I doing wrong?
    Thanks
    Edited by: Kind_of_Green on May 5, 2008 3:55 PM
    Edited by: Kind_of_Green on May 5, 2008 4:00 PM

    OK... so you WERE absolutely right about the src path for the image tag.
    However I also had another problem that was quite a bit more insidious and mostly just a symptom
    of how little I know about what goes on under the hood of a web app.
    My bean storing the image info was stored as a request attribute. When the servlet was called from the
    jsp page the request object was either reset or just never initialized. Anyway it is not the same request
    object I assumed it was being passed in the doGet method. I added my bean as a session
    attribute and everything is sparkly :)
    I can only assume that when a request is neither forwarded nor included (as is the case with
    calling the servlet from the img tag) it is disappeared.
    Anyway, thanks a mint man. I so totally appreciate your time.
    Ciao :)

  • Please Help:(,Unable to capture from camcorder using Audigy 2 ZS Video Edi

    Hi there! Well I have been trying to use the Sound Blaster Audigy 2 zs video editor to transfer Hi8 tapes from my camcorder (Samsung SLC860) to my laptop (Compaq presario, AMD Athlon 64 3200+, .25 GB RAM, xp). I have successfully done this before *sort of*. Before i was able to capture video from my camcorder without the sound. But now I cant even capture video! I get an error when using Ulead VideoStudio 8 SE reading: 5065:29:0. Please help, anything would be great! Thank you! Oh, i've tried reinstalling the drivers already, didnt work. P.S. I connect the camcorder to the Creative Audigy using S-Video. I have also tried A/V out from the camcorder to video-in on the Audigy. I have also downloaded VidCap and other driver updates from Creative but those didn't work either. I've tried VidCap other capture programs, none worked. Any help would be great. Thank you!
    Message Edited by DjShadowalker on <SPAN class=date_text>06-06-2006 <SPAN class=time_text>:09 AM
    Message Edited by DjShadowalker on 06-06-2006 :09 AM

    Hi there! Thanks for the reply, unfortunately, I've tried VidCap and it wont let me capture either. The Start button on Step 3 isn't acti've. Its not bold, and when i click on it nothing happens. But under device manager and Sound, Video and game controllers, there are alot of things. They are as followed: Audio Codecs, Legacy Audio Drivers, Legacy Video Capture Drivers, Media Control Devices, Sound Blaster Audigy 2 ZS Video Editor Audio Device, Sound Blaster Audigy 2 ZS Video Editor Video Device, SoundMAX Intergrated Digital Audio, Video Codecs. Do you think any of these could be interfering with one another? If so, which ones can be safely disabled? I've also tried downloading all the necessary updates for VidCap and I've even tried reinstalling the Audigy card many times. I am able to see the preview of the video on both programs VidCap and VideoStudio but I just can't capture. Once again, the error message on VideoStudio is: 5065:29:0. Thank you so much, hopefully I hear from ya soon and this can be fixed.

  • How can I follow-up directly to apple, for my defective iphone5. They promise to replace it but then it's been a month. I want to know when exactly will I get the replacement. PLEASE HELP ME. Im from the Philippines.

    I just bought my iphone5 last march 27, but then after a few weeks I noticed that there is something loose inside of it. So I went to Globe Philippines, a telecommunications company in the Philippines and one of the authorize distributor of iPhones here ib the country, but instead of just replacing my defective phone, the advised me to wait for 3 to 4 weeks for them to be able to replace it because the replacement unit will be coming from Apple Singapore. I said ok then, but It's already a month now, still there is no feedback regarding the status of my phone. PLEASE HELP ME! Apple Singapore, Im begging you to replace my phone.

    All support for your iPhone in the Philippines is handled by Globe, so you need to continue to work with them on the issue. No one here can help you directly with this issue, nor is there any way you can yourself contact the repair depot in Singapore (if indeed that's where it is). You can, however, try calling Apple Support in the Philippines at 1-800-1441-0234, ask to speak with someone in Customer Relations, and ask if there's anything they can do to help expedite the process.
    Regards.

  • Please Help Get a Color from Pixel !!!!

    Is anybody know how to get a Color from pixel.
    My program is not Full Screen .
    So i think Robot.getPixelColor() don't suitable.
    Please Help me!

    Robot.getPixelColor() will work fine, but the problem you will have is getting the mouse set to the correct location and getting your application to know where it is: you can do it with win32 calls and JNI. Here are a few that I have found helpful--they are in a VB format:
    Public Const CLR_INVALID = &HFFFF 'not a valid pixel
    Public Const MOUSE_MOVED = &H1
    Public Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
    Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
    Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
    Public Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
    Public Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
    Public Const REQUEST_LEFT_CLICK = &H2D 'request left click "-"
    Public Const REQUEST_RIGHT_CLICK = &H2B 'request right click "+"
    Type POINTAPI
    x As Long
    y As Long
    End Type
    Type POINTSTRUCT
    hwnd As Long
    hdc As Long
    ptAbsolute As POINTAPI
    ptOrigin As POINTAPI
    ptLocal As POINTAPI
    ptColor As Long
    sType As String
    retMessage As Boolean
    End Type
    Declare Function GetCursorPos _
    Lib "user32" (ByRef lpPoint As POINTAPI) _
    As Long
    Declare Function SetCursorPos _
    Lib "user32" (ByVal x As Long, ByVal y As Long) _
    As Long
    Declare Sub mouse_event _
    Lib "user32" (ByVal dwFlags As Long, _
    ByVal dx As Long, _
    ByVal dy As Long, _
    ByVal cButtons As Long, _
    ByVal dwExtraInfo As Long)
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Declare Function GetMessageExtraInfo Lib "user32" () As Long
    Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
    ByVal x As Long, _
    ByVal y As Long) As Long
    Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, _
    ByVal yPoint As Long) As Long
    Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function GetWindowOrgEx Lib "gdi32" (ByVal hdc As Long, _
    ByRef lpPoint As POINTAPI) As Long

  • Please help me capturing data from HTML table

    Hello Everyone,
    Our Storage subsystem generates a html table containing all LUN allocation for printing. I am saving this html file on disk to collect all table infomation and to put it into a database.
    I am having problems extracting table information from the html file. I tried using regular expressions but still not going anywhere. Below is a sample few lines from the html file.
    Please your help is appreciated solving this problem how to collect this information from a HTML file or if Java has any class for this type of purpose.
    Please advice
    arsi
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <!-- saved from url=(0068)https://10.210.44.14/cgi/rsConfigPrintDisplay?200702121685061633,FS,2 -->
    <HTML><HEAD><TITLE>Volume Assignments</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <META content="MSHTML 6.00.2900.3020" name=GENERATOR></HEAD>
    <BODY><FONT face="Times New Roman,Times" size=2>
    <TABLE cellSpacing=1 cellPadding=3 border=2>
    <CAPTION>
    <H2>Volume Assignments</H2></CAPTION>
    <TBODY>
    <TR vAlign=top>
    <TH><FONT face="Times New Roman,Times" size=2>Volume</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Location</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>LSS</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Volume Type</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Size</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Storage Type</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Host Port</FONT></TH>
    <TH><FONT face="Times New Roman,Times" size=2>Host Nicknames</FONT></TH></TR>
    <TR vAlign=top>
    <TD><FONT face="Times New Roman,Times" size=2>02A-25015</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>Device Adapter Pair 1</FONT>
    <BR><FONT face="Times New Roman,Times" size=2>Cluster 1, Loop A</FONT>
    <BR><FONT face="Times New Roman,Times" size=2>Array 2, Vol 042</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>0x10</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>Open System</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>000.9 GB</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>RAID-5 Array</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>Fibre Channel</FONT>
    <BR><FONT face="Times New Roman,Times" size=2>ID 00, LUN 502A</FONT></TD>
    <TD><FONT face="Times New Roman,Times" size=2>R1L01_0,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>R1L01_1,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>R2L08_1,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>R2L08_0,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>S3L06_0, S3L06_</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>1, S4L06_0,</FONT> <BR><FONT
    face="Times New Roman,Times" size=2>S4L06_1</FONT></TD></TR>
    <TR vAlign=top>

    i wrote the programme for 2 stepper motor as attachment file below. they are run. but when the "start" button is ON then the "emergency stop" is not effects.
    for "emergency stop" functions, i used 4 limit contactors. if one of them is "on" then the programme will be stop.
    but in fact, when the system is running, i can not stop if one of the limit contacor is on.
    cuold you please help me to do with this problem.
    thanks
    Attachments:
    EMERGENCY STOP.vi ‏435 KB
    toolpaths-ut.vi ‏64 KB
    parallel program motor 1,2.vi ‏96 KB

  • I want to arrange / organize my photos in the various EVENTs, how is this being done ??? please HELP, thank you, manfred from jupiter

    I  have set up several EVENTs for my photos in iPhoto. Now when I click on an Event, I want to arrange the pictures within this event , when I click on the picture  I  want to move, it does not move, it stays in place. ( yellow fram around the picture does appear )  I clicked on the VIEW tab, selected " sort EVENTS" than I slide over to manually and  the word appears in grey rather than black .  Therefore I am unable to move the picture to the place I want it to be within that same event.  Please be kind and Help,  thank you,  manfred from jupiter

    Hello Old Toad,
    thank you for your reply, very much appreciated.
    I am sending you the same anwer I sent out to LarryHN, since it covers the ame topic.....
    My version of iPhoto is  :  " iPhoto  08 " , version 7.1.5  ( 378 )
    I set up an " Album " as you suggested and this procedure works,  I am able in this new Album to change the pictures around as I want it to be.
    However in checking back at the same  " Event"  Album / Gallery  the pictures still remain the old way and do not show the changes I made in the new Album version.
    I guess that's the way it will be. Take it or leave it..... or do you have another suggestion ????  Thank you for looking into my problem. Please let me know.  Thank you  again manfred from jupiter

  • Please help with ejecting disk from MBP that won't book

    I was in the middle of installing a Leopard update when my MBP froze.
    Since I had to tunr it off, it now won't start up.
    I tried a friends OSX install disk to get it working and it won't install.
    Please help me eject the disk.
    No matter what I do I cannot get it out.
    IS there a Terminal prompt to eject it.
    The install disks won't allow the command under disk utilities because it is starting up with that disk.
    PLease help.

    hold down the trackpad button while rebooting the computer

  • OS 10.6 - Please help - problem restoring system from time machine!

    Hi there,
    Today I installed a little program to convert flac audio files to mp3. When I ran the program the computer froze, so I rebooted but then I could move the cursor but not click on any menus or icons on the desktop, they just wouldnt respond - so basically I couldnt use the computer. After re-booting a few times with the same result I decided to reinstall the system using time machine from an external hard drive. I reinstalled OSX, then reinstalled Snow Leopard, then reinstalled the system from a previous save from Time Machine. It said the installation was successful, but when the computer restarted a message comes up saying "You need to restart your computer. Hold down the Power button until it turns off, then press the Power button again". Ive done this about 5 times now but it always just says the same message without starting properly. WHAT DO I DO???? I really need to use my computer tomorrow so any help is hugely appreciated!!! TIA
    PS. i have done a hardware test in "loop mode" and it says everything is fine

    HiDef Jules wrote:
    Hi there,
    Today I installed a little program to convert flac audio files to mp3. When I ran the program the computer froze, so I rebooted but then I could move the cursor but not click on any menus or icons on the desktop, they just wouldnt respond - so basically I couldnt use the computer. After re-booting a few times with the same result I decided to reinstall the system using time machine from an external hard drive. I reinstalled OSX, then reinstalled Snow Leopard, then reinstalled the system from a previous save from Time Machine.
    how exactly did you reinstall the system from TM? please give details. the correct way to do it is to boot from the snow leopard DVD and use the "restore system from backup" utility in the Utilities menu. there is no need to reinstall anything prior to using that utility. the restore utility wipes your hard drive and restores it to the state it was in at the backup time.
    It said the installation was successful, but when the computer restarted a message comes up saying "You need to restart your computer. Hold down the Power button until it turns off, then press the Power button again". Ive done this about 5 times now but it always just says the same message without starting properly. WHAT DO I DO???? I really need to use my computer tomorrow so any help is hugely appreciated!!! TIA
    PS. i have done a hardware test in "loop mode" and it says everything is fine

  • Please Help/ GUI Calculator

    I'm trying to create a GUI Calculator but cannot get my program to compile. Please could someone assistm, thanks.
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CalculatorFrame extends JFrame
         private Container contentPane;
         //The componenets used in the calculator
         private JTextField display;
         private JButton addition;
         private JButton subtract;
         private JButton multiply;
         private JButton divide;
         private JButton mod;
         private JButton enter;
         private JButton [] digits;
         //End of components
         //Integer representations for the arithmetic operations needed
         private final static int ADD = 1;
         private final static int SUB = 2;
         private final static int MUL = 3;
         private final static int DIV = 4;
         private final static int MOD = 5;
         //ENd of arithmethic operations
         //Integer holding the operator that the user requested
         private int op;
         //Boolean variable to help perform the calculations
         private boolean firstFilled;
         private boolean clearScreen;
         //Constructor for the class
         public CalculatorFrame()
         contentPane=new Container();
         this.setSize(400,300); //sets the size of the frame
         this.setTitle("MIS 222 Calculator"); //sets the title of the frame
         //allows the "X" box in the upper right hand corner to close the entire application
         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         contentPane=this.getContentPane(); //gets the content pane
         //Methods
         addDisplay();
         addDigits();
         addDigitActionListeners();
         addOperation();
    private void addDisplay()
         JLabel displayLab = new JLabel("Answer");
         JPanel north = new JPanel();
         north.add(displayLab);
         contentPane.add(north, "North");
    //diplay was already declared above the constructor
         display = new JTextField(25);
    //adding the components to the panel
         north.add(displayLab);
         north.add(display);
    //adding the panel to frame's content pane
         contentPane.add(north, "North");
    //Declaring the global digits array
    private void addDigits()
         //Add 1 large panel to hold the 3 inner panels
         JPanel digPanel = new JPanel();
         //Set the panel's preferred size so that it will keep everything in line
         digPanel.setPreferredSize(new Dimension(200, 275));
         //Initialize the top 3 digits' JPanel and set its preferrd size
         JPanel topDigits = new JPanel();
         topDigits.setPreferredSize(new Dimension(200,60));
         //Initialize the middle 2 digits' JPanel and set its preferred size
         JPanel midDigits = new JPanel();
         midDigits.setPreferredSize(new Dimension(200,60));
         //Initialize the bottom digits' JPanel and set its preferred size
         JPanel botDigits = new JPanel();
         botDigits.setPreferredSize(new Dimension(200, 75));
         //Initialize the JButton array
         digits = new JButton[11];
         //Initialize each of the top Panel's digit buttons, and add it to the top panel
         for(int i=1; i<4; i++)
              String lab=(new Integer(i)).toString();
              digits=new JButton(lab);
              topDigits.add(digits[i]);
              //Adding the top Digit Panel to the overall digit panel
              digPanel.add(topDigits, BorderLayout.CENTER);
              //Adding the middle Digit Panel to the overall digit panel
              digPanel.add(midDigits, BorderLayout.CENTER);
              //Adding the bottom Digit Panel to the overall digit panel
              digPanel.add(botDigits, BorderLayout.CENTER);
              //Add the overall digit Panel to the Frame's contentpane
              contentPane.add(digPanel, BorderLayout.CENTER);
              //Method created to add the DigitAction Listeners
              addDigitActionListeners();
    //Method created to add all of the DigitActionListeners
    private void addDigitActionListeners()
              for(int i=0; i<10; i++)
                   digits[i].addActionListener(new DigitActionListener(i));
              digits[10].addActionListener(new DigitActionListener("."));
    //DigitActionListener class
    public class DigitActionListener implements ActionListener
         private String myNum;
         public DigitActionListener(int num)
              myNum=""+num;
         public DigitActionListener(String num)
              myNum=num;
         public void actionPerformed(ActionEvent e)
              if(display.getText().equals("Please enter a valid number")|| clearScreen)
                   clearScreen=false;
                   display.setText("");
    //OperatorActionListener class
    public void OpActionListener implements ActionListener
         private int myOpNum;
         public OpActionListener(int op)
              myOpNum=op;
         public void actionPerformed(ActionEvent e)
         {  //Checks to see if the user has already enterd a number
              if(!firstFilled)
              try{
                   //Parse the number entered
                   String number=display.getText();
                   dNum1=Double.parseDouble(number);
                   //Sets the flag for the firstFilled to true
                   firstFilled=true
                   //Sets the op variable so when the "Enter" button is pressed, it will know which operation to perform
                   op=myOpNum;
                   //Clears the textbox
                   display.setText("");
                   catch(Exception er)
                        display.setText("Please enter a valid number");
         //This is the second number being entered
              else{
                   try{
                        String number=display.getText();
                        String result;
                        dNum2=Double.parseDouble(number);
                        firstFilled=true;
                        op=myOpNum;
                        display.setText("");
                   catch(Exception er)
                        display.setText("Please enter a valid number");
    private void addOperation()
         JPanel opPanel=new JPanel();
         opPanel.setPreferredSize(new Dimension(75,200));
         JButton clear = new JButton("C");
         JButton addition = new JButton("+");
         JButton subtraction = new JButton("-");
         JButton multiply = new JButton("*");
         JButton divide = new JButton("/");
         JButton mod = new JButton("%");
         JButton enter = new JButton("Enter");
         addition.addActionListener(new OpActionListener(ADD));
         subtraction.addActionListener(new OpActionListener(SUB));
         multiply.addActionListener(new OpActionListener(MUL));
         divide.addActionListener(new OpActionListener(DIV));
         mod.addActionListener(new OpActionListener(MOD));
         clear.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent e)
                   display.setText("");
                   firstFilled=false;
         enter.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent e)
                   double result;
                   String answer="";
                   String number = display.getText();
                   dNum2 = Double.parseDouble(number);
                   dNum1=Double.parseDouble(number);
                   switch(op)
                        case ADD:
                             result = dNum1 + dNum2;
                             break;
                        case SUB:
                             result = dNum1 - dNum2;
                             break;
                        case MUL:
                             result = dNum1 * dNum2;
                             break;
                        case DIV:
                             result = dNum1 / dNum2;
                             break;
                        default:
                             result= -1.0;
                             break;
                        if(result==(int)result)
                             answer=(new Integer((int)result)).toString();
                        else
                             answer=(new Double(result)).toString();
                        display.setText(answer);
                        clearScreen=true;
                        firstFilled=false;
                        dNum1=0;
                        dNum2=0;
              opPanel.add(clear);
              opPanel.add(addition);
              opPanel.add(subtraction);
              opPanel.add(multiply);
              opPanel.add(divide);
              opPanel.add(mod);
              opPanel.add(enter);
              contentPane.add(opPanel, "East");
         //Creating the frame object
         public class CalculatorMain
              public void main(String[] args)
                   CalculatorFrame cf=new CalculatorFrame();
                   cf.show();
    ERRORS THAT I HAVE!!:
    javac calculatorframe.javacalculatorframe.java:150: '(' expected
    public void OpActionListener implements ActionListener
    ^
    calculatorframe.java:7: class CalculatorFrame is public, should be declared in a file named CalculatorFrame.java
    public class CalculatorFrame extends JFrame
    ^
    calculatorframe.java:54: cannot resolve symbol
    symbol : method addOperation ()
    location: class CalculatorFrame
    addOperation();
    ^
    3 errors
    >

    Hi, actually it's all written there:
    >
    ERRORS THAT I HAVE!!:
    javac calculatorframe.javacalculatorframe.java:150: '(' expected
    public void OpActionListener implements
    ActionListenerpublic void ... is part of a possible method signature. That's probably why the compiler expects '(' as this is need for a method.
    To define a class use:
    public class ... (or better: private class ..., if the class is not used outside of this file.
    ^
    calculatorframe.java:7: class CalculatorFrame is
    public, should be declared in a file named
    CalculatorFrame.java
    public class CalculatorFrame extends JFrame
    ^As it says, you defined a class CalculatorFrame in a file calculatorframe.java. But the file name should be the same as the class name (case sensitive). Java classes should start with capital letters, so rename the file to:
    CalculatorFrame.java
    calculatorframe.java:54: cannot resolve symbol
    symbol : method addOperation ()
    location: class CalculatorFrame
    addOperation();
    ^
    3 errors
    >You didn't declare the method 'addOperation' (-> cannot resolve symbol; which simbol: method addOperation (); where: location: class CalculatorFrame; you see it's all there)
    Note there is a method called 'addOperation' in the class OpActionListener, but not in CalculatorFrame.
    Note I didn't read the code, just the error messages. I hope this helps.
    -Puce

Maybe you are looking for

  • How to configure java.security file to run j2ee programs

    Hi, I am using Sun one application server to run my j2ee programs. plz tell me how to configure java.security file inside my appserver so that i can run my servlet program that is using jsse API to create SSL sockets. I am not able to follow whats th

  • Set_window_property('forms_mdi_window',window_state,minimize) not working

    Hi all, set_window_property('forms_mdi_window',window_state,maximize) is working but set_window_property('forms_mdi_window',window_state,minimize) not working! mdi window is not displayed. when i am typing minimize it turns into blue which should not

  • Windows 8.1 keeps forgetting my network credentials

    I frequently need to access files on my (Qnap TS-109II, Samba-based) NAS so I connect to \\server\share using the "Remember my credentials" checkbox. Alas, I often get errors (e.g. with File History, or just accessing a share from Windows Explorer's

  • 10.1.3.3 setup Java problem when upgrading from 10.1.3.2

    Hi guys! I have a problem with upgrade from 10.1.3.2 to 10.1.3.3 on Windows The documentation is old what you can download! So I cannot find anything. The Infrastructure Installation and Configuration Guide is for 10.1.3.2.1 and from april 2007 The I

  • How to choose member position during ERPi metadata load ?

    Dear All , We are using ERPi to load data and metadata from EBS to our target Hyperion Planning Application . during metadata load , members set to be at the root of the dimension . My question , How to choose where the extracted members to be placed