Simple calculator, but ...

Hi !
I'm looking for some simple calculator (+,-,*,/) implemented in java using session bean, but unfortunetly I can't find any. Already I've come accross on many examples but without these mentioned beans.
Please, if you have any working link, or even code - I would be very grateful.

and what would you learn by downloading some code someone else wrote and submitting it to your teacher as your own?

Similar Messages

  • Simple calculation - but wrong output?

    I have:
    System.out.println(3 * 0.2);But the outputs 0.6000000000000001 instead of 0.6.
    Why?

    [Performing exact calculations with floating-point numbers|http://java.sun.com/developer/JDCTechTips/2001/tt0807.html#tip1]
    [Some things you should know about floating-point arithmetic|http://java.sun.com/developer/JDCTechTips/2003/tt0204.html#2].
    [What Every Computer Scientist Should Know About Floating-Point Arithmetic|http://docs.sun.com/source/806-3568/ncg_goldberg.html]
    [Floating point - From Wikipedia, the free encyclopedia|http://en.wikipedia.org/wiki/Floating_point]
    ~

  • I have set up a override box for a simple calculation but it appears that it doesn't work in reader just pro.

    Here is what I have in the JavaScript Editor and it works when I use Adobe Acrobat Pro but when I download this pdf form to our extranet (which uses reader) I am unable to change the value when the override box is checked.  I have very limited knowledge of javaScript so any help would be greatly appreciated.
    In the SALE box I am trying to override I have:
    var g=this.getField("SELL");
    var f=this.getField("RATE_2");
    if(this.getField("override").value=="Off"){
    event.value=((g.value*f.value)/100);
    In the override box - mouse up run javascript I have:
    if(event.target.value=="Off"){
    this.getField("SALE").readonly=true;
    }else{
    this.getField("SALE").readonly=false;

    Are you sure you're using Adobe Reader? This code should work fine there.
    On Feb 24, 2015 12:04 AM, "christies3837445" <[email protected]>

  • Simple calculations not working in acrobat 9

    I have text form fields made in Acrobat 9 from a previously made pdf, where I need a simple calculation, but I cannot get it to work.
    The form is not for submission, only for personal tracking, so I don't even need validation.
    FieldA (a number they enter) x a number I have entered in the calculation = FieldB
    FieldB x FieldC (a number they enter) = FieldD In FieldB I have a simple javascript Calculation in the form field: FieldA * .115, which should automatically calculate answer into FieldB, when tabbed.
    In FieldD I have a Calculation in the form field: FieldB * FieldC, which should automatically calculate answer into FieldD. All fields are set as numbers.
    I have left the Trigger Action as Mouse Up.
    I don't need to validate, as this is personal use, and is not being submitted.
    I have all fields in the correct tab order.
    I have reader enabled the form. When I open the form in Reader, I can enter the numbers, but no calculations are being performed. It reads 0 in FieldB and FieldD. Any assistance would be greatly appreciated.

    Hello Everyone,
    I use the following VBS code, but to tell the truth, I don't know if it works or not. The main idea was to enable commenting from Adobe Reader. But after execution code, saving document and reopening it in Reader, commenting is still 'Not Allowed'. Is showAnnotToolsWhenNoCollab really capable to allow this and there is only error in my code? Or is the functionality different and this way can never be used for what I want?
    There is another issue that application is not closed on Exit, but is still shown.
    scriptPath = "C:\Acrobat\"
    Set gApp = CreateObject("AcroExch.App")  
    Set pdDoc = CreateObject("AcroExch.PDDoc")
    sampleFilePath = scriptPath & "AR_test_orig.pdf"
    pdDoc.Open sampleFilePath
    pdDoc.OpenAVDoc "myFile"
    gApp.Show
    Set formApp = CreateObject("AFormAut.App")
    'formApp.Fields.ExecuteThisJavascript "app.alert(""hello"");"
    formApp.Fields.ExecuteThisJavascript "Collab.showAnnotToolsWhenNoCollab = true;"
    Set formApp = Nothing
    pdDoc.Save 1, scriptPath & "AR_test.pdf"
    'pdDoc.Close
    gApp.CloseAllDocs
    gApp.Exit
    Set pdDoc = Nothing
    Set gApp = Nothing
    Thanks for any ideas.
    Jan
    PS: I use Acrobat 9.0 Pro

  • Simple calculations in Universe not working for XI 3.0

    Simple calculations in Universe using key figures are not working in XI 3.0(without any Fix Pack)
    Below is the steps I followed.
    1. Using key figure [Jan] I am trying to round the values by deviding it by 1000.
    <EXPRESSION>@Select([Jan])/1000</EXPRESSION>
    This gives me a null cell value.
    2. I tried addition then
    <EXPRESSION>@Select([Jan])+1000</EXPRESSION> result was all the cell values changed to 1000.
    3. Finally without calculation I tried
    <EXPRESSION>@Select[Jan]</EXPRESSION> this also resulted null value
    But without EXPRESSION tag if I try @Select[Jan] it works fine.
    Am I missing anything in above expressions.
    As of now I am creating variable in report to incorporate the rounding.
    Thanks
    Raghu

    It was my mistake while writing the question. Path I have used is correct one only @Select(Key Figures/.
    If i use the above alone, I am able to se the data. But if I use in betwen <EXPRESSION> then it gives null value.
    Note: Pls dont confuse with flower bracket i used it just to avoid coverting it to a html link and also the backslash it was not showing in preview
    I have followed that pdf and created calculation in universe.
    Edited by: Raghavendra Barekere on Feb 6, 2009 6:42 AM

  • Add a simple calcul to a table with Personalize menu

    Hi
    is it possible to add a column (Message Styled Text) that will do a simple calculation ((score +50 *10000) /quote total) in an existing table (Personalize "Supplier Summary Table")
    thanks

    Thank you Bernd, but that is only part of the solution.  For example, I do set the Page Layout to 1-page-continuous.  MOST of the time it keeps this setting, but some documents either override that setting, or perhaps it reverts back to a default (maybe with version upgrades?).  The other part is that I always want the menu-bar and toolbar to show up.  Some documents hide these when they open.  I realize that I can hit [F8] and/or [F9] to toggle these, but there are additional settings.  I also want to always have the selection tools available, etc.  Bottom Line: I just want a collection of settings that I can call up with a single, simple shortcut or button, so I don't have to perform multiple steps just to get the tool back to my standard configuration whenever something changes it.

  • Flash rookie needs help with error messages when making simple calculator in AS3.

    I am trying to make a simple calculator I have been following this guide:
    http://www.youtube.com/watch?v=5k3h37YKZJI
    this is my code.
    var Hnum:String;
    var PCnum:String;
    var calc:Number = 25;
    var Total:String;
    num1.restrict = "0-9";
    num2.restrict = "0-9";
    Est_btn.addEventListener(MouseEvent.CLICK, calculate);
    function calculate(event:MouseEvent):void{
        Hnum = num1.txt;
        PCnum = num2.txt;
        Total = parseInt(Hnum) * calc;
        Total.toString();
        Total_txt.text = String(Total);
    I am getting these 3 errors:
    Scene 1, Layer 'Actions', Frame 1, Line 14
    1067: Implicit coercion of a value of type flash.text:TextField to an unrelated type String.
    Scene 1, Layer 'Actions', Frame 1, Line 15
    1067: Implicit coercion of a value of type flash.text:TextField to an unrelated type String.
    Scene 1, Layer 'Actions', Frame 1, Line 16
    1067: Implicit coercion of a value of type Number to an unrelated type String.
    I have two input text boxs named num1 and num2 and then one dynamic text box named Total_txt.
    This should be so simple I really don't know what im doing wrong?
    Any help would be really appreciated.
    MrB

    If you look at the tutorial I think you will see that you are using "txt"  where "text" is required.  "text" is a property of a textfield, identifying the text that the textfield holds.  I don't know if you are doing something where the num1 object contains another object named txt, but I think my first sentence catches the problem.

  • Web Dynpro Application For developing a simple calculator

    Dear Experts,
    I am trying to develop a simple calculator application in abap web dynpro .
    but i am not able to enable the buttons (1 to 9) . that is what i want is like how it happens in a normal calculator if we press 1 , then in the screen, 1 comes and if 11 then twice we press 1. Like wise i want if the button 1 is enabled then in the input field it should take 1 and if 11 then it should take 11. Kindly give some suggestions to develop this application.
    Regards
    Swarnadeepta

    Hi Swarnadeepta,
    I developed a calculator in web dynpro...please go through the following code. I have made a few changes with respect to modularization but the basic concept is still the same.
    Method to Enter Data on the screen
    METHOD enter_data .
      DATA lv_input TYPE i.
      DATA lv_flag TYPE c.
    ***Read input in the screen 
    wd_this->get_input(
        IMPORTING
          ev_input = lv_input                       " integer
    ***See whether flag is set. If yes save the present value in global attribute gv_previous.
      wd_this->get_flag(
        IMPORTING
          ev_flag = lv_flag                        " wdy_boolean
      IF lv_flag = 'X'.
        wd_this->gv_previous = lv_input.
        lv_input = 0.
      ENDIF.
    ***Modify screen input
      IF lv_input IS INITIAL.
        lv_input = iv_number.
      ELSE.
        lv_input = lv_input * 10 + iv_number.
      ENDIF.
    ***Set the new value of input field
      wd_this->set_input(
        iv_input = lv_input                          " integer
    ***Reset the flag
      wd_this->set_flag(
        iv_flag = ''                           " wdy_boolean
    ENDMETHOD.
    Use the above method on button click
    method ONACTIONONE .
      wd_this->enter_data(
        iv_number = 1                        " integer
    endmethod.
    Method to Register Operations
    method ENTER_OPERATION .
      wd_this->set_flag(
        iv_flag = 'X'                           " wdy_boolean
      wd_this->set_operation(
        iv_operation = iv_operation                      " string
    endmethod.
    Use of above method in operations button
    method ONACTIONADD .
      wd_this->enter_operation(
        iv_operation = 'ADD'                     " string
    endmethod.
    Method to calculate
    method ONACTIONEQL .
    DATA lv_operation TYPE string.
    DATA lv_input TYPE i.
    ***Read screen input 
    wd_this->get_input(
         IMPORTING
           ev_input = lv_input                        " integer
    ***read operation requested
      wd_this->get_operation(
        IMPORTING
          ev_operation = lv_operation                   " string
    CASE lv_operation.
    WHEN 'ADD'.
    lv_input = wd_this->gv_previous + lv_input.
    WHEN 'SUB'.
    lv_input = wd_this->gv_previous - lv_input.
    WHEN 'MUL'.
    lv_input = wd_this->gv_previous * lv_input.
    WHEN 'DIV'.
    lv_input = wd_this->gv_previous / lv_input.
    WHEN OTHERS.
    ENDCASE.
    ***Set the new value of input field
      wd_this->set_input(
        iv_input = lv_input                         " integer
    ***Clear the operation attribute
      wd_this->set_operation(
        iv_operation = ''                     " string
    endmethod.
    Getter Methods example for attribute INPUT
    method GET_INPUT .
      DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->element_context.
      DATA lv_input TYPE wd_this->element_context-input.
    get element via lead selection
      lo_el_context = wd_context->get_element( ).
    @TODO handle not set lead selection
      IF lo_el_context IS INITIAL.
      ENDIF.
    get single attribute
      lo_el_context->get_attribute(
        EXPORTING
          name =  `INPUT`
        IMPORTING
          value = lv_input ).
    EV_INPUT = lv_input.
    endmethod.
    Setter Methods example for attribute INPUT
    method SET_INPUT .
      DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->element_context.
      DATA lv_input TYPE wd_this->element_context-input.
    get element via lead selection
      lo_el_context = wd_context->get_element( ).
    @TODO handle not set lead selection
      IF lo_el_context IS INITIAL.
      ENDIF.
    @TODO fill attribute
    lv_input = iv_input.
    set single attribute
      lo_el_context->set_attribute(
        name =  `INPUT`
        value = lv_input ).
    endmethod.
    Hope this will be helpful. Let me know if you have any doubt.
    Its working fine for me.
    Regards,
    Sayan

  • How to create a simple calculated measure ?

    Hello,
    I'm having difficulties creating a very simple calculated measure within OBIEE administrator. Let's say I have a dimension "product" with attribute "product price" and a measure "sales count". I'm trying to define in the "Business Model" layer the calculated measure "total sales". In order to do that I defined it as as a Logical Column with expression "product price" * "sales count".
    However OBIEE doesn't compute what I'm expecting, it does in fact a cartesian product of the products and the grand total sales, which doesn't make sense. To alleviate that I tried to define the measure as associated to the Product level, then I get the computations right but the sales by product are not summed into a grand total.
    Anyway this seems like a very basic thing to do but I've not been able to find any documentation about it; the internal "Help" documentation is extremely limited. Is there another source of documentation that I'm not aware of ?
    Thanks for your help,
    Chris

    Hi there again,
    I'm coming back to you regarding the calculated measure above. As advised, I defined it using physical columns and am - almost - able to get the correct results. However I notice that the measure is not correctly aggregated over the "product" dimension. More specifically what happens is that the products are organized into a level-based hierarchy; only the leaf elements have an attibute "price"; the upper nodes in the hierarchy group different products together with different prices.
    The "total price" measure for such a node should be the sum of "product price" * "sales count" for all underneath nodes in the hierarchy, which is the way it is done for instance in AWM. However with the measure defined as above, I only get NULL values for upper nodes, due to the fact that "product price" is NULL for those levels and thus yields a NULL result.
    I've tried to circumvent the problem by associating the measure to the leaf level of the "product" hierarchy in the Properties -> Levels tab, however this doesn't seem to do what I want, it only forces the computation to happen at the lowest level of the hierarchy. What I would like is for the measure to aggregate to upper levels just as it would were it defined directly in AWM.
    Do you know how to do that ?
    Thanks for your help!
    Chris

  • Creating a simple calculator

    Hi all. I realize this might fall into the dumb question category, but I can't find any tutorials or walkthroughs on it.
    I want to make a simple calculator. The user inputs the variables and that changes the values displayed.
    I have all of the formulas as a table in Excel. I imported the data source (Excel), created a gallery and connected the various input and text boxes to the corresponding column labels in Excel.
    But when you change the values in the text input box the other fields don't change. It's almost like Siena forgot the formulas and is just displaying the text.
    Any help or directions to a tutorial would be greatly appreciated.
    Thanks!

    Hi,
    When importing data from Excel, Siena retains the values not the initial formula. So you will need to create these formula using Siena expressions.
    As a simple example, let's assume you want to add the values of two input visuals and display the result in a lablel, the text expression of that label would be:
    label: InputText1!Text+InputText2!Text
    Olivier

  • Override Simple Calculation

    Hello everyone, I have no idea about javascript but would like to know if someone can help me with this simple calculation. What I want is for the field to calculate the amount due for an item which has a price of $ 108, but if the rep wants to override the total amount to leave the overwritten amount on.
    On the field I am doing the calculation (RESULT) I would like it to calculate the quantity on the EEQTY field * 108, and then let the user override the amount if they feel like it, so it would go like this:
    RESULT = EEQTY * 180 or whatever the guy puts on the RESULT field
    I will then be adding all the RESULT fields in order to make up the total.
    Thanks in advance!

    You can use a script like the following so that the RESULT field only calculates if the EEQTY field is changed:
    // Custom calculation script for RESULT field
    (function () {
        // Get a reference to the quantity field
        var f = getField("EEQTY");
        // Only calculate if a change in the quantity triggered this script
        if (event.source && event.source === f) {
            event.value = util.printf("%.2f", +f.value * 108);  // Round to nearest cent

  • Simple calculation involving  KOMV-KBETR giving issues

    Hello Experts,
    I have a pricing routine in which I am doing some calculation on a field typed on KOMV-KBETR. The calculation is similar to the code  shown below. But this simple calculation is not giving correct results. For example, the correct result from the sample code below should have been 180.00, but the result I am getting is 18000.00. Please help to resolve this. Thanks in advance
    Also, if you try to execute the below code in a custom program, you will get the correct result. But the issue is happening in a pricing routiine.
    TABLES: komv.
    DATA:  ws_value LIKE komv-kbetr VALUE '200.00',
                 g_value TYPE bsgrd value '90.00'.
    IF sy-subrc EQ 0.
      ws_value = g_value * ws_value / 100.
    ENDIF.
    Regards
    Arun.

    - How did you fill KOMV (are you in an exit, a specific program, do you use a FM like PRICING_GET_CONDITIONS ?)
    - Is KOMV-WAERS currency key filled (?)
    Nevertheless - from [Predefined ABAP Types|http://help.sap.com/saphelp_wp/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/frameset.htm]
    it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
    You can convert from currency to decimal field using FM for BAPI like BAPI_CURRENCY_CONV_TO_EXTERNAL and BAPI_CURRENCY_CONV_TO_INTERNAL. (or old FM like CURRENCY_AMOUNT_SAP_TO_DISPLAY)
    Regards,
    Raymond

  • Please a simple problem but I don't know how to solve it. After installing 16 gb of ram all is good but when I turn on the computer it is a window signaling that all is correct. How is possible to delete once and for all that window? Thank you

    Please a simple problem but I don't know how to solve it. After installing 16 gb of ram all is good but when I turn on the computer it is a window signaling that all is correct. How is possible to delete once and for all that window? Thank you

    Well then maybe you could take a screenshot because the appearance of such a window is news to me.
    Also post your OS X version and what model Mac you have. The more detail, the better. Thanks.
    To take a screenshot hold ⌘ Shift 4 to create a selection crosshair. Click and hold while you drag the crosshair over the area you wish to capture and then release the mouse or trackpad. You will hear a "camera shutter" sound. This will deposit a screenshot on your Desktop.
    If you can't find it on your Desktop look in your Documents or Downloads folder.
    When you post your response, click the "camera" icon above the text field:
    This will display a dialog box which enables you to choose the screenshot file (remember it's on your Desktop) and click the Insert Image button.
    ⌘ Shift 4 and then pressing the space bar captures the frontmost window.
    ⌘ Shift 3 captures the entire screen.
    Drag the screenshot to the Trash after you post your reply.

  • I have a pc and downloaded a trial version of Adobe Acrobat DC to create pdfs. I have followed the simple instructions but what I get is an entire screen shot saved instead of just my document. The instructions seem so simple. I can't imagine what I am do

    I have a pc and downloaded a trial version of Adobe Acrobat DC to create pdfs. I have followed the simple instructions but what I get is an entire screen shot saved instead of just my document. The instructions seem so simple. I can't imagine what I am doing wrong. Have project I need to submit today. Please help.

    Unfortunately, what you describe isn't a common problem. It is pretty surprising, but hopefully it's a simple as clicking or pressing the wrong thing. So, to find this out we need to know, step by step, at the most basic level, what you click or type EXACTLY and what you see. That should let us get to the cause.

  • Need help with starting a simple calculator

    I have this simple calculator I just started on, and I'm having just a few problems. First of all, I don't know how to append text to a textfield. Maybe I would have to create a string buffere or something. Then, when the user clicks one of the buttons, the compiler goes crazy, and nothing is displayed.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Calculator extends JFrame implements ActionListener
         JButton[] btnNums;
         JButton btnBack;
         JButton btnClear;
         JButton btnCalculate;
         String[] strNames;
         JTextField txtDisplay;
         public Calculator()
              Container content = getContentPane();
              setSize(210,250);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              /*  construct a JPanel and the textfield that
               *  will show the inputed values and outputed
               *  results
              JPanel jpDisplay = new JPanel();
              jpDisplay.setLayout(new BorderLayout());
              txtDisplay = new JTextField(15);
              txtDisplay.setHorizontalAlignment(JTextField.RIGHT);
              jpDisplay.add(txtDisplay);
              /*  contstruct a JPanel that will contain a back
               *  button and a clear button.
              JPanel jpRow2 = new JPanel();
              btnBack = new JButton("Backspace");
              btnClear = new JButton("Clear");
              btnClear.addActionListener(this);
              jpRow2.add(btnBack);
              jpRow2.add(btnClear);
              /*  construct a string array with all the names of the
               *  buttons, then in a for loop create the new buttons
               *  and add their name and an actionListener to them.
              String[] strNames = {"7","8", "9","/", "4", "5", "6","*", "1", "2", "3","+", "0", "+/-", ".", "-"};
              btnNums = new JButton[16];
              JPanel jpButtons = new JPanel();
              jpButtons.setLayout(new GridLayout(4,4));
                for (int i = 0; i < 16; i++)
                     btnNums[i] = new JButton(strNames);
                   btnNums[i].addActionListener(this);
                   jpButtons.add(btnNums[i]);
              /* construct the final JPanel and add a
              * calculate button to it.
              JPanel jpLastRow = new JPanel();
              btnCalculate = new JButton("Calculate");
              btnCalculate.addActionListener(this);
              jpLastRow.add(btnCalculate);
              /* set the contentPane and create the layout
              * add the panels to the container
              setContentPane(content);
              setLayout(new FlowLayout());
              setResizable(false);
              content.add(jpDisplay, BorderLayout.NORTH);
              content.add(jpRow2);
              content.add(jpButtons);
              content.add(jpLastRow);
              setTitle("Mini Calculator");
              setVisible(true);
         public void actionPerformed(ActionEvent ae)
              for (int i =0; i < 16; i++)
                   if (ae.getSource() == btnNums[i])
                        txtDisplay.setText(strNames[i]);
         public static void main(String[] args)
              Calculator calc = new Calculator();

    First of all, I don't
    know how to append text to a textfield.
    textField.setText( textField.getText() + TEXT_YOU_WANT_TO_APPEND );
    Then,
    when the user clicks one of the buttons, the compiler
    goes crazy, and nothing is displayed.No, the compiler doesn't go crazy, the compiler has done it's job by then. However, you do get a NullPointerException, and the stacktrace tells you that the problem is on the following line:
    txtDisplay.setText(strNames);
    It turns out that strNames is null. I leave it to you to find out why. ;-)

Maybe you are looking for