How to add User Inputs?

Well I'm new to Java, and I was trying to make a basic calculator to add 2 user inputs and give a total. Here is my code:
import java.util.Scanner;
public class calculator {
     public static void main(String[] args) {
          int total;
          Scanner number1 = new Scanner(System.in);
          Scanner number2 = new Scanner(System.in);
          System.out.print("Enter your first number: ");
          System.out.println(number1.nextLine());
          System.out.print("Enter your second number: ");
          System.out.println(number2.nextLine());
          total = number1 + number2;
          System.out.print("Your total is: " + total);
}And here is my error:
C:\Users\Jennifer\Desktop\Vincent's Things>javac calculator.java
calculator.java:13: operator + cannot be applied to java.util.Scanner,java.util.
Scanner
                total = number1 + number2;
                                ^
1 errorI tried giving it a cast, since it's saying Scanner's can't be operated, such as:
          total = (int)number1 + (int)number2;But that didn't work. How can I make it so it adds the two inputs?

A Scanner is a Scanner. Of course you can't just add two Scanners together. The Scanner could also be used to read text. A Scanner can't read your mind to know what type of data you are reading. You have to tell the Scanner what type of data you are reading. They way you do that is to read the Scanner API and use the proper methods.

Similar Messages

  • How to get User input in JTextField?

    How to get User input in JTextField? Can u anyone give me some code samples? thanks

    read the API!!!

  • How to take user input and place it in a variable

    All I want to know is how to copy user input from the message pop up and store in a local variable?
    Thanks.

    Hi
    Just take a look at thread's example
    http://forums.ni.com/t5/NI-TestStand/TestStand-Message-Popup/m-p/1792424/highlight/true#M35397
    The trick is done by Message-Popup PostExpression: Locals.strMyResponse = Step.Result.Response
    Hope this helps
    Juergen
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=

  • How to get user input to keep in array in the form of int[]?

    I really want to know how to get user input to keep in an array. Or if it's impossible, can i use the value in "int" and transfer it to an array?

    What I understand is that you want to set an input from the user in an array of int.
    Here is how it work:
    1. Create a stream and a buffer to get and store the informations entered by the user:
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    2. Set this input in a String:
    String input = stdin.readLine();
    3. Set this string in an int:
    int userInput = Integer.parseInt(input);
    4. Then you can put this int in the array.
    Warning this code throws IOExceptions and NumberFormatException ( when you try to set letters as int ). But you can catch them easily.

  • How to add user defined tab in the Header level of T-Code O4NM?

    How to add user defined tab in the Header level of  T-Code O4NM?
    I tried with BADI but I cant able to find any BADI for it and also searched for screen exit too..

    Can you check the user exits,
    OIJNOM_N and OIJTKT_N
    Cheers,
    Balaji

  • How to add users from person or group field in a sharepoint list to sharepoint group

    Hi,
    How to add users(single or multiple) from person or group field in a sharepoint list to sharepoint group programmatically?
    Any suggestions would be appreciated.
    Thank you,
    AA.

    Hello,
    Use SPGroup.AddUser() method to add user in group. I have just written sample code in notepad so it is not tested:
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using(SPSite Site = new SPSite(SPContext.Current.Site.Url))
    Using(SPWeb Web = Site.OpenWeb())
    SPList list = web.Lists["ListName"];
    SPQuery query=new SPQuery ();
    query.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Test</Value></Eq></Where>";
    SPListItemCollection items = list.GetItems(query);
    if(items.Count > 0)
    foreach(SPListItem item in items)
    //Get USers from person or group column
    SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users");
    SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString());
    SPGroup spGroup = spSite.RootWeb.Groups[groupName];//group name
    if (users.Count != 0)
    bool isUserInGroup = false;
    foreach (SPFieldUserValue user in users)
    foreach (SPUser item in spGroup.Users)
    string itemUserName = item.LoginName;
    string UserName = user.User.LoginName;
    if (itemUserName == UserName)
    isUserInGroup = true;
    break;
    if (!isUserInGroup)
    spGroup.AddUser(user.User);
    The above code will query list item and then get users from "Users" column. Now it will check whetehr user is already in group not, if not then add user in group.
    http://rajanijilla.blogspot.sg/2012/09/add-users-to-group-programmatically.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to add users to group which is present in another AD domain?

    Hi,
    Using JNDI how to add user as a member of group which is present in another AD domain?
    For example: In AD forest test.com their are two domain a.test.com and b.test.com. Group is present in a.test.com and I want to add user present in b.test.com as a member of the group.
    Any pointer around this would be great help.

    See the below link to get an idea on group types.
    http://technet.microsoft.com/en-us/library/cc755692(v=ws.10).aspx
    If the group is a universal group, you can just add members similar to local group even if user and group are in different domains. That is by setting the member attribute of the group.

  • How to add users to OSM using UserAdmin.xsd

    Hi,
    Can you please explain me how to add users to OSM using UserAdmin.xsd i.e xml import/export tool. I need the steps how to do that..
    Thanks in Advance,
    Menaka

    Hi Razvi444,
    You need to use submit data to web service in Submit button rule,where you can use above web service.
    Refer http://office.microsoft.com/en-in/infopath-help/submit-form-data-to-a-web-service-HA010107048.aspx more details
    Thanks

  • How to add User Permissions to form created in InfoPath 2010 created for SharePoint document Library

    Hi,
    I created a form in InfoPath 2010 with three views (one for user input, the other two views to be used by supervisors) and published this to a SharePoint 2010 document library. Now the way this form is supposed to work is that when a User goes to the document
    library and adds a document, it is supposed to open the Form with the User's input view. When the User submits the document, only him/her should be able to open and possibly edit the the form. When the Immediate Supervisor opens the form, it should open in
    the Supervisors view and allow them to fill in only their section and not be able to edit or alter the user's data. When the Immediate Supervisor saves the document, the Over-all Supervisor should be able to open it in their view and not be able to edit or
    alter the sections filled out by the User and Immediate Supervisor.
    How would i go about completing this? I have the views created but now have the problem of associating these views with their respective users or groups.

    Hello,
    You need to first create user group in sharepoint site then add user in group according to their role. Later you need to call usergroup.asmx web service to get current logged-In user group name so you can switch view and also apply rule for editing or disabling
    controls in form.
    Follow this link to get group name:
    http://social.technet.microsoft.com/wiki/contents/articles/13271.sharepoint-2010-extracting-user-group-of-current-login-user-in-infopath-2010.aspx
    http://social.msdn.microsoft.com/Forums/en-US/018f5184-5c83-4a53-b66b-8c376fc800fc/how-to-get-current-users-sharepoint-group-name-sharepoint-2010-infopath-2010
    To apply rule on control:
    http://office.microsoft.com/en-in/infopath-help/add-rules-for-performing-other-actions-HA101783373.aspx
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Add User Input in Email Notification Template

    Hi all, I'm new to SM and in need of anyone's assistance. I've created a service request and in the template under User Input, I have it requesting the "New Users Name" and the "Start or Termination Date". I'd like to add these 2
    inputs into my Email Notification Template. How can this be done? I've been able to insert the Title, Requestor, Alternative Number, and Description in the Template Design but can't seem to find where I can add these Inputs. Any help would be
    appreciated. Thanks in advance.

    Hi,
    Please refer to the link below:
    E-mail user from Service Manager Console
    http://blogs.technet.com/b/servicemanager/archive/2010/02/02/e-mail-user-from-service-manager-console.aspx
    Moreover, the video  [09:00-11:00 min] might be help you:
    Demo: Automating Service Request Fulfillment from the SCSM Service Catalog with Orchestrator
    http://blogs.technet.com/b/servicemanager/archive/2011/11/09/demo-automating-service-request-fulfillment-from-the-scsm-service-catalog-with-orchestrator.aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • How to capture user input for customer exit processing?

    I need to calculate the number of working days elapsed in the current fiscal quarter BASED on the USER INPUT on the reporting front.  i.e., say the fiscal quarter started on 1 July 2005 and if the user enters 10 July 2005, I should get the value 8 (Assume that Monday through Friday are all workdays).  If the user enters 12 July 2005, I should get 10.  I have written customer exits and know how to use factory calendar, but <b>THE CHALLENGE</b> is how do I <b>CAPTURE</b> the user input and use it in my exit?  During the varible definition, if I select the check box "Ready for input" then the customer exit is not being processed and unless I check that box I can't get a user entry!  If I look at the import values in the customer exit, I see i_t_var_range with type rrs0_t_var_range.  My strong feeling is that this parameter gets the user input, but I am unable to use it as the customer exit is not being called if I make the user to input the data.  Based on the empirical evidence, I felt that user input and customer exit can not co-exist!!  Please somebody prove me wrong and let me know how can I use the user input to process my "customer-exit" variable.  I would really appreciate any input from the BW community here.

    Hi Sameer,
    Most likely, I'm missing something, but I think that the answer is very simple.
    CASE I_VNAM.
    WHEN 'YOUR_CUSTOMER_EXIT_VAR'.
    IF I_STEP = 2. “ After selecting of input variable
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'USER_INPUT_VAR'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(4).
    APPEND L_S_RANGE TO E_T_RANGE.
    ENDLOOP.
    ENDIF.
    ENDCASE.
    In this typical user exit coding you have a user entered value in LOC_VAR_RANGE (originally in I_T_VAR_RANGE) and you construct your user exit variable value in E_T_RANGE.
    Best regards,
    Eugene
    Message was edited by: Eugene Khusainov

  • How to add an input field in the web UI of CRM 2007

    Hi everybody.
    I want add an Input field in the Web UI Screen. How it is possible.
    I want get the information with detailed descriptions if possible with screen shorts.
    What type of methods it will be generated and what are the code we entered in those methods.
    Take according to any example. But with detailed description.
    I am new for the CRM 2007. So, please give the screen shorts with proper data.
    Not only adding the field. If any data i entered in the adding field then that will be stored in the tables otherwise no use by adding the field.
    So, Can anybody please send a proper information according to this.
    Here another one How to Add our own table (Ztable) field in the Web UI Screen.
    How to add the same field in the BOL.
    Please expalin about those concepts with full of screen shorts messages.
    Thank You.
    Regards,
    Krishna.

    If you want to add extra standard fields (like one you mentioned), you can use Component Workbench and Copy the configuration and create your own configuration and make the "Available Fields" appear there.
    If the standrd field is not available, you can Add Context Node using wizard and make it visible.
    If its a custom field (a new one); you will have to use EEWB and add the fields and then make it visible in the UI using Component Workbench.
    Regards,
    Alin

  • In XML Gateway Responsibility How to add User defined Trading Partner type.

    Hi,
    We have a requirements to add user defind Trading Partner Type apart from the default trading partner type.
    How to do this? If any one know , kinldy let me explain it
    Thanks

    I looked it up in the mean time ...
    The docs state that you only can use simple data type or java.util.list or AttributeList (which is a wrapper for any viewRow). So I guess you have to somehow flatten your complex data type or create a custom VO which holds it.
    http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcextservices.htm#CJAEHFJD
    Scroll down to 11.2.3
    Timo

  • How to accept user inputs from  sql script

    I want to create Tablespace useing sql script , but the location of the data file I need accept from user . (to get the location of the data file ) .
    How can I accept user input from pl/sql .
    Example :
      CREATE TABLESPACE  TSPACE_INDIA LOGGING
         DATAFILE 'H:\ORACLE_DATA\FRSDB\TSPACE_INDI_D1_01.dbf'
         SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL;here I need to accept location of the datafile from user ie : 'H:\ORACLE_DATA\FRSDB\TSPACE_INDI_D1_01.dbf'

    Hi,
    Whenenever you write dynamic SQL, put the SQL text into a variable. During development, display the variable instead of executing it. If it looks okay, then you can try executing it in addition to displaying it. When you're finished testing, then you can comment out or delete the display.
    For example:
    SET     SERVEROUTPUT     ON
    DECLARE
        flocation     VARCHAR2 (300);
        sql_txt     VARCHAR2 (1000);
    BEGIN
        SELECT  '&Enter_The_Path'
        INTO    flocation
        FROM    dual;
        sql_txt :=  'CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING
         DATAFILE' || flocation || ' "\SRC_TSPACE_INDI_D1_01.dbf" ' || '
         SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL ';
        dbms_output.put_line (sql_txt || ' = sql_txt');
    --  EXECUTE IMMEDIATE sql_txt;
    END;
    /When you run it, you'll see something like this:
    Enter value for enter_the_path: c:\d\fubar
    old   5:     SELECT  '&Enter_The_Path'
    new   5:     SELECT  'c:\d\fubar'
    CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING
         DATAFILEc:\d\fubar
    "\SRC_TSPACE_INDI_D1_01.dbf"
         SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE
    UNLIMITED
         EXTENT MANAGEMENT LOCAL  = sql_txt
    PL/SQL procedure successfully completed.This makes it easy to see that you're missing a space after the keyword DATAFILE. There are other errrors, too. For example, the path name has to be inside the quotes with the file name, without a line-feed between them, and the quotes should be single-quotes, not double-quotes.
    Is there some reason why you're using PL/SQL? In SQL, you can just say:
    CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING
    DATAFILE  '&Enter_The_Path\SRC_TSPACE_INDI_D1_01.dbf'
    SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL;though I would use an ACCEPT command to given a better prompt.
    Given that you want to use PL/SQL, you could assign the value above to sql_txt. If you need a separate PL/SQL variable for flocation, then you can assign it without using dual, for example:
    DECLARE
        flocation     VARCHAR2 (300)     := '&Enter_The_Path';The dual table isn't needed very much in PL/SQL.
    Edited by: Frank Kulash on Jan 10, 2013 6:56 AM

  • How to give user input in flsh animation??

    i m a student of engineering and my project is to create animation of dc motors whose parameters can be controlled by user input
    means current,voltage and speed of the rotor...how con i do it...
    m totally new iin this field and learning flash...
    and can i make these type of animation in flash professional CS5???

    What you should probably consider is using Slider components to control each of the parameters.  There should be examples of how to use them in the help documentation.

Maybe you are looking for

  • Problem generating index with 2th level in cs4

    Windows XP sp 3 - Indesign CS4 601 When generating an index with a 1st and a 2th level, in the 2th level the entry of the 1st entry is always repeated. E.g. the index should look as this: text     75      capitalized     76      import     78 word   

  • Import service Purchase order

    Hi Experts, I am facing  this problem when i am creating import service Purchase order with Purchase requisition. my import pricing procedure have Assessible value percentage condition type,which is coming in import service PO with certain percentage

  • AOL and iChat work sometimes

    I am trying to figure out why AOL and iChat work sometimes and other times it doesn't. I am trying to video chat with a family member and some of the time I can make a connection just fine and other times we get error code 8. If it was a firewall iss

  • I have lost all icons cannot get them to stay on the screen just flash on then go

    i am having trouble getting icons to come up on ipad4 they just flash on then go help please

  • Need more options for display

    Is it possible to add more option like "default date format mask" for results that are output in the grid? I am using this product since this AM and I already love it. ps: Will this be the right forum to request nwe enhancements? Raj