Really simple question PLZ help

A very very simple method.
User types input 3 times.
First two times enters integer numbers. The third input has to be +, -, * or /.
The method uses the third input as an operator to perform the addition if it is +, subtraction if - etc.
How do i turn the user input into an operator?
The method's parameters are three.
public int performAction(int num1, int num2, ???operator???)
It returns an int which is the result of : num1 operator num2
Thank you.
papei
Edited by: papei on Oct 27, 2007 6:09 AM
Edited by: papei on Oct 27, 2007 6:43 AM

papei wrote:
A very very simple method.
User types input 3 times.
First two times enters integer numbers. The third input has to be +, -, * or /.
The method uses the third input as an operator to perform the addition if it is +, subtraction if - etc.
How do i turn the user input into an operator?
The method's parameters are three.
public int performAction(int num1, int num2, ???operator???)
It returns an int which is the result of : num1 operator num2
Thank you.
papei
Edited by: papei on Oct 27, 2007 6:09 AM
Edited by: papei on Oct 27, 2007 6:43 AMSo you want to make a calculator?
.. and what have you done so far..?

Similar Messages

  • Help with Forte: very simple question, please help!

    I recently downloaded the community version of Forte (Sun One) but can't seem to get any new empty class programs to execute properly. I know something is probably not set up right, which is why I really need a little help to get started. Regardless of the code I try to execute, the output error is always:
    "java.lang.NoClassDefFoundError: (name of program)
    Exception in thread "main" "
    Please let me know what I'm not doing right. I would really appreciate anybody's thoughts on this problem because I would love to get Forte working so I can start learning Java. Thanks for your input!

    I would tell you that Forte is not a tool for the beginner. you should look at something simpler. Forte is a fully integrated development environment. I would look at a simple editor like emacs, available at gnu.org. The commands of this editor are quite difficult to get use to.
    As for setting the class varialbe. It depends on the O/s that you are using. win98/me is different than NT/xp. Need to know one or the other before explaining.
    email me if you have question. email address is in my profile.

  • A simple question please help.

    Hi
    I have 2 textfields and a button. I want to input a number( diameter) in the first textfield  ( inputField) and by clicking on the button (myButton), I want to get the result (circonference) in the second textfield ( inputField1). diameter*3.14. I know it is a simple question, but it comes from a very simple mind. So have mercy on me.
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    import flash.events.MouseEvent;
    var inputField:TextField = new TextField();
    var myFormat:TextFormat = new TextFormat();
    myFormat.size = 44;
    inputField.defaultTextFormat = myFormat;
    inputField.restrict = "0-9";
    inputField.maxChars = 6;
    inputField.multiline = false;
    inputField.textColor = 0x000000;
    inputField.border = true;
    inputField.width = 150;
    inputField.height = 50;
    inputField.x = 75;
    inputField.y = 50;
    inputField.borderColor = 0xFF0000;
    inputField.type = "input";
    addChild(inputField);
    var inputField1:TextField = new TextField();
    var myFormat1:TextFormat = new TextFormat();
    myFormat1.size = 44;
    inputField1.defaultTextFormat = myFormat;
    inputField1.maxChars = 1;
    inputField1.multiline = false;
    inputField1.textColor = 0x000000;
    inputField1.border = true;
    inputField1.width = 150;
    inputField1.height = 50;
    inputField1.x = 275;
    inputField1.y = 50;
    inputField1.borderColor = 0xFF0000;
    addChild(inputField1);
    myButton.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
       trace("Mouse clicked");

    use:
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    import flash.events.MouseEvent;
    var inputField:TextField = new TextField();
    var myFormat:TextFormat = new TextFormat();
    myFormat.size = 44;
    inputField.defaultTextFormat = myFormat;
    inputField.restrict = "0-9";
    inputField.maxChars = 6;
    inputField.multiline = false;
    inputField.textColor = 0x000000;
    inputField.border = true;
    inputField.width = 150;
    inputField.height = 50;
    inputField.x = 75;
    inputField.y = 50;
    inputField.borderColor = 0xFF0000;
    inputField.type = "input";
    addChild(inputField);
    var inputField1:TextField = new TextField();
    var myFormat1:TextFormat = new TextFormat();
    myFormat1.size = 44;
    inputField1.defaultTextFormat = myFormat;
    inputField1.maxChars = 1;
    inputField1.multiline = false;
    inputField1.textColor = 0x000000;
    inputField1.border = true;
    inputField1.width = 150;
    inputField1.height = 50;
    inputField1.x = 275;
    inputField1.y = 50;
    inputField1.borderColor = 0xFF0000;
    addChild(inputField1);
    myButton.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
    inputField1.text=String(Math.PI*Number(inputField.text));

  • 2 Simple Questions Plz

    i really need help with this, i am currently using the java tutorial on this site, i am having trouble understanding 2 things, how to use timers and how to use JTabbedPane. i am learning to use these things in swing so if you could make a swing program for me to look at i would appreciate it. Doesnt have to be to complex, infact make it simple for me to understand. Thanks alot in advanced!

    The Swing tutorial comes with working examples and explanations of how the examples work. Download those examples and run them.
    Why would our examples be any better than the ones in the tutorial?
    If you have a specific question about a piece of the code in the tutorial then ask it, but don't ask for general code, thats what the tutorial is for.

  • Question: plz help in this

    hi,
    in XI how we will maintain for a perticular file for example at a particular time.like the poll interval if maintained at 30sec the porocessor will check the record for every 30sec but if we want to schedule at 12:00 every day to check for the record then how can we do that.
    if there is any code that need to be written plz provide code or if any steps involved plz explain in detail
    byeee

    Hi Anshul
    Simple. Set the polling interval value as Example ((  86400 (12460*60) )) and activate the channel at 6 PM.
    Another option : Use availablity timings and set the timing for the sender communication channel from 6 PM to 6:30 PM every day and in the cc give the polling interval value larger than 1800 (may be 2000).
    just check this blog.. it talks about the same
    /people/shabarish.vijayakumar/blog/2006/11/26/adapter-scheduling--hail-sp-19-
    In your query you can use datepart() function to check the time is 6p.m or not
    i.e in your Query add this where clause....
    where datepart(hh,getdate()) = '18'
    Refer :http://help.sap.com/saphelp_nw70/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
    <b>Check tHis thread discuss sthe same</b>
    Assigning an exact time to poll data using JDBC Sender?
    Regards
    Abhishek

  • Problem in a webdynpro abap component - Really very urgent PLZ help me

    Hi Experts,
    I am working with FITV_POWL_TRIPS webdynpro component.In that my requirement is to keep a button and input fields near the create travel request button and to add some functionalities.
    I worked in the  component , unfortunately the component get corrupted. i don't know how to retrieve the component to its original state.I tried with version management but no use.
    Can anybody suggest me how to retrieve the component. Any of your inputs is valuable to me.
    if the patch should be installed is the only way mean plz tell me the patch details.
    Actually FITV_FPM  , this component get damaged. This component is under FITV_POWL_TRIPS.
    Regards,
    Ramanan
    Edited by: Ramanan Panchabakesan on Jul 9, 2008 12:10 PM

    Dear Thomas,
    Really i failed to use the enhancement mode to work with that POWL component.Actually the thing i did is added an attribute directly to the component controller of that component and  binded it to the drop down then activated , it shows some error "Configuration missing error" so again i deleted that attribute and reactivated it again but it shows the same error. so i tried to retrieve it back from version.But failed, then compared with other system the methods and attributes are same as it is.Finally copied the methods and code from that system though all are same in two systems, then activated.No error now.But clicking on the "create request" button the component shows a road map step with 1 as completed status.It looks with the following information
    Fite_Request
          1
    Completed
    and with two buttons one is disabled and thats capiton is Previous step and the other is exit that is enabled
    when i clicked that exit button it again goback to the intial screen of FITV_POWL_TRIPS.
    Before it shows with some 3 or 4 road map steps with some different status.
    Tell me any other way to retrieve it.As the patch to be  reinstalled is the solution means please tell in which patch this resides.Technically i want to retrieve it, going for patch update is secondary and i go for that if and only if there is no other way.
    with hope and regards,
    Ramanan.P
    Edited by: Ramanan Panchabakesan on Jul 15, 2008 7:34 AM

  • Really simple question, stop function and scroll bar won't work

    I was working on different parts of this VI separately, when I put them together the scroll bar and stop button stopped working. 
    In the individual VI both are in the while loop. In the final one I was one scroll bar and one stop button to apply to all 5 while loops.
    I tried taking the scroll bar in and out of the first loop to attach it to the rest but it still won't work.
    I'm sure that there is a really stupid simple answer but I've been playing with it for a while.
    I attached the VI that I am working on as well at fake data (to test the color boxes).
    Thanks!
    Solved!
    Go to Solution.
    Attachments:
    trial8.vi ‏95 KB
    trial8.vi ‏95 KB
    0_1024.txt ‏25 KB

    You have a typical beginner problem due to incorrect understanding of dataflow. Run the code using execution highlighting and watch the diagram to see.
    Your stop button is outside any loop and thus will only be read by the code exactly once at the start of the program.
    Your scroll bar is read in the first loop. All other loops cannot start until the first loop has completed and since (1) is true, it will never happen if the boolean is false when the code starts.
    Why do you have so much duplicate code? 95% of the loop code is the same and can be re-used. I am sure the entire thing could be written using 5% of the total code. Put everything in one loop, the iterate over the 2D array to get all the values. Don't forget to place a small wait inside the while loop.
    LabVIEW Champion . Do more with less code and in less time .

  • Really simple question i'm sure

    this is the first time i'm using iMovie, so bear with me. i have a handheld digital camera that records the video fine, uploads to my computer fine (in mpg format), but when i try to import the file it saves, it won't do it. i've also tried to import the files straight from the camera. please help, thanks.

    nevermind i'm an idiot. someone asked the same question down below, and i figured it out through their thread. i just needed to change the mpeg to a .mov or .avi. thanks anyway though.

  • Very simple question pls help me

    I just want to use oracle sql and pl/sql workshop isqp*plus web site, so which product or software shouuld i download??? pls help me.
    thanks.

    Pl see your other 2 threads on the same topic (posting the same question multiple times does not make the issue go away ;-) )
    Oracle install error 10g 64 bit windows
    which product should i install??
    HTH
    Srini

  • Reports questions plz help me

    1)How to create a button in selection screen?can u explain with simple example?
    2)How to add a gui status in a selection screen?can u explain with simple example?
    3)can you call a bdc program from a report? how? can u explain with simple example?
    4)can you call a transactionfrom a report? how? can u explain with simple example?
    5)how to create a check box option in a list? can u explain with simple example?

    HI
    <b>1)How to create a button in selection screen?can u explain with simple example?</b>
    eg:
    SELECTION-SCREEN PUSHBUTTON /15(20) button1 USER-COMMAND EXEC1.
    SELECTION-SCREEN PUSHBUTTON /15(20) button2 USER-COMMAND EXEC2.
    You can initialize the texts for the push-buttons at INITIALIZATION.
      CONCATENATE icon_green_light
                  'Button 1'(029) INTO button1.
    You can select the icon if needed,
    AT SELECTION SCREEN.
      CASE sscrfields.
        WHEN 'EXEC1'.
           perform subroutine1.
        WHEN 'EXCE2'.
           perform subroutine2.
      ENDCASE.
    <b>2)How to add a gui status in a selection screen?can u explain with simple
    example</b>
    The GUI status of a selection screen is generated by the system. The SET PF-STATUS statement in the PBO event of the selection screen has no effect on the standard GUI status. If you want to use your own GUI status for a selection screen or deactivate functions in the standard GUI status, you can use one of the following function modules in the PBO event of the selection screen:
    RS_SET_SELSCREEN_STATUS
    Sets another GUI status defined in the same ABAP program, or deactivates functions of the standard GUI status.
    RS_EXTERNAL_SELSCREEN_STATUS
    Sets a GUI status defined in an external function group. You must use the SET PF-STATUS statement to set the status in a special function module in this function group. You must pass the name of the function module that sets the status as a parameter to the function module RS_EXTERNAL_SELSCREEN_STATUS.
    check the links
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba66935c111d1829f0000e829fbfe/content.htm
    Re: how to add my  own pf status to selcetion screen.
    http://help.sap.com/saphelp_46c/helpdata/en/e7/0eb237e29bc368e10000009b38f8cf/content.htm
    <b>3)can you call a bdc program from a report? how? can u explain with simple example?</b>
    If the BDC program is ZBDC01.
    then you can call it Using:
    SUBMIT ZBDC01
    AND RETURN.
    BDC program it self we wrote in report editor
    <b>4)can you call a transactionfrom a report? how? can u explain with simple example?</b>
    by creating a transaction code for that report by going into
    GOto SE93 and create by giving the Program name and the Screen number which will be shown at the start of the transaction. For a REPORT it will be 1000.
    Alternatively in SE80 if you open you program and right click on the program name you get a menu option Create->Transaction.
    specify screen no and program name
    <b>5)how to create a check box option in a list? can u explain with simple example?</b>
    /community [original link is broken]
    <b>Reward if usefull</b>

  • A very simple question, please help.

    How would I output/print out a string in color rather then the standard black?
    If anyone can help me or point me in the right direction would be greatly appreciated.
    For example for extra clarification, if I want to print out a string "Hello World", how can I print it out in different colors such as in blue or red.
    Output to a JApplet ( TextArea)
    Thanks!
    Edited by: ff4930 on Nov 30, 2007 9:18 AM

    You can change the colour of all the text in a JTextArea by setting its foreground property:
    yourComponent.setForeground.setColor(Color.RED);If you just want have multiple colors in one JTextArea, that's not possible. You will have to use a more advanced component, like JEditorPane or JTextPane:
    http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
    In basic cases, if the text doesn't have to be editable by the user, you can use a JLabel and pass it simple html:
    String text = "<html><font color='red'>red text</font> " +
    "<font color='green'>green text</font> " +
    "<font color='blue'>blue text</font></html>";
    yourLabel.setText(text);

  • Simple query plz help

    hi experts
    i have a variable in which i have stores a date
    from that date i want to store only the month value in a seperate variable .
    plz give me the code for this
    thanks in advance .

    Here is the code:
    data: l_datum like sy-datum.
    data: l_month(2) type c.
    Assign value to L_DATUM
    l_month = l_datum+4(2).
    Hope this helps.
    ashish

  • html:select and html:options simple question  - please help

    Hi Friends,
    I am having a problem, please help me .I want to run a query and display all the lastnames of all the users in my database.Here are my files:
    UserForm.java
    public class UserForm extends ActionForm{
         private name firstName;
         private name lastName;
         //all getter and setters
    viewuser.jsp
    <html:select property="lastName">
        <html:options collection="users" property="lastName" labelProperty="lastName" />
    </html:select>
    and my Java Utility class method
    public ArrayList getusers() throws Exception {
             ArrayList aList = new ArrayList();     
              Connection con = ConnectionUtil.getConnection();
              PreparedStatement stmt = null;
              try {
                   stmt = con.prepareStatement("select last_name from USERS);     
                   ResultSet rs = stmt.executeQuery();
                      if (rs.next()) {
                          aList.add(rs.getString(1));
                      }else {
                           return null;
                      rs.close();
                      return aList;
              } catch (SQLException e) {
                   e.printStackTrace();
                   throw new ServiceProcessingException(e.getMessage());
              } finally {
                   ConnectionUtil.closeStatement(stmt);
                   ConnectionUtil.closeConnection(con);
         }My problem is what i need to do in my Action class,so that it sets the "users" variable
    properly and i would be able to read that variable in my jsp and display the lastname
    of all the users.I am tryin this but failing badly:
    public class UserAction extends Action{
      ArrayList userssList = Utility_class_obj.getUsers();
      request.getSession().getServletContext().setAttribute("users", usersList);Please Please help,I would really appreciate your help.
    Thanks

    Thanks a lot friend...this time i made it work my style,next time i will use tha mehod.But I think I am not doing it the right way,please correct me:
    This is the method in my utility class where i run the query and I doubt I am not doing it right here:
    PreparedStatement stmt = null;
    ViewForm vForm = null;
    try {
    stmt = con.prepareStatement("SELECT LAST_NAME FROM   USERS_ADD");     \
    ResultSet rs = stmt.executeQuery();          
    while(rs.next()) {
           vForm = new ViewForm(rs.getString(1));          
          aList.add(vForm);          
       rs.close();
       return aList;          }
    }And I made this constructor in my viewForm class:
    public ViewForm(String lastName){          this.setLastName(lastName);     }I do this in my Action class then:
    ArrayList pList = csDAO.getUsers();  
         if(pList  != null){         
         request.getSession().getServletContext().setAttribute("plist", pList);      
    }And finally this in my jsp:
        <html:select property="lastName"> 
        <html: options collection="plist" property="lastName" labelProperty="lastName" /> And it works,but i don't think I can keep adding constructors to my form class like that,and moreoever if I want to search by first name ,there would be a conflict between 2 constructors,so can someone please tell me the right way to do this.
    Thanks
    Mick

  • I buy iTunes card and I can't download cuz I forget the answer of the questions :( plz help-! How can I send the card from the acc to my new one .

    I wrote everything up ^

    You need to ask Apple to reset your security questions; ways of contacting them include clicking here and picking a method for your country, phoning AppleCare and asking for the Account Security team, and filling out and submitting this form.
    Putting the card's balance back onto it and then to the new one also requires contacting Apple.
    (97325)

  • Simple question, please help

    I just need to know right now can SSL be used for secure FTP to send commands and data over separate channels, and if so, how? I want to replace a simple FTP socket connection with a secure one, nothing fancy. I don't want to use HTTP unless I absolutely have to. Any advice would be appreciated.

    Has anyone evaluated all the different options available and found the better alternatives? I have found SSH Communications Security's SSH Secure Shell, RSA Security's BSafe SSL-J, ValiCert's SecureTransport (a.k.a. FileDrive) and others. I haven't compared them in detail yet and was hoping to get some advice from others out there who are doing the same sort of thing.

Maybe you are looking for

  • Exchange 2013 STD - Capacity Limits

    Hi, I plan to deploy, exchange 2013 STD with 400 users. I understand the exchange STD 2013, supports 5 mounted (active mailbox database). ---> I've seen the mailbox database can grow to 2 TB size limit. Questions: 1. What is the maximum mailboxes can

  • Evaluate function problem

    I have a problem with EVALUATE function in OBIEE. I passed two parameters. Number is numeric and Name is varchar. Evaluate('DWH.PKG_ITEM_FUNCTION.PS_LAW(%1,%2)', "Book"."Item"."Number", "Book"."Item"."Name" ) I get the following error: [nQSError: 220

  • Java Local Cache Outperformed C++ Local Cache in 3.6.1

    Currently I'm using same local cache configuration to publish 10000 record of a portable object and retrieve same item few times from both Java and c++ client with oracle coherence 3.6.1 version. I'm using linux x86 version for both java and c++. Res

  • Network UI element and Java 8

    Hello everybody! We are using the "Network" UI element (JNet) in one of our WD Java applications (NW 7.3.1 SP 11). This element consists of an obviously unsigned Java applet (which my local Java 7 JVM complained about for some time). Anyway the apple

  • How do i convert to pdf?

    how do i convert to pddf?