How to  Get input from  User and Display it's Value

Hi ,
I need to get 2 inputs from user and to display it's Mutilple Value.
The Below Code is working fine to get 2 Input's from user,but it display a Junk value as a Result .How to
overcome this Problem. I need to display it's Mutilple(a*b) value of "a " and " b".
import java.io.*;
class Mul{
static int a=0;
static int b=0;
static int Count=0;
public static void main(String args[])throws IOException{
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
do{
a=(char)br.read();
Count++;
b=(char)br.read();
if(Count==2)
System.out.println("The Multiplied Value is "+a*b);
}while(Count<2);
}

Changed to Integer but still the problem persists.
import java.io.*;
class Mul{
static int a=0;
static int b=0;
static int Count=0;
public static void main(String args[])throws IOException{
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
do{
a=(int)br.read();
Count++;
b=(int)br.read();
if(Count==2)
System.out.println("The Multiplied Value is "+a*b);
}while(Count<2);
}

Similar Messages

  • How to Get Input From User and Display Result

    Hi ,
    I need to get 2 inputs from user and to display it's Mutilple Value.
    The Below Code is working fine to get 2 Input's from user,but it display a Junk value as a Result .How to
    overcome this Problem. I need to display it's Mutilple(a*b) value of "a " and " b".
    import java.io.*;
    class Mul{
    static int a=0;
    static int b=0;
    static int Count=0;
    public static void main(String args[])throws IOException{
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    do{
    a=(char)br.read();
    Count++;
    b=(char)br.read();
    if(Count==2)
    System.out.println("The Multiplied Value is "+a*b);
    }while(Count<2);
    }

    Hi ,
    I need to get 2 inputs from user and to display it's
    Mutilple Value.
    The Below Code is working fine to get 2 Input's from
    user,but it display a Junk value as a Result .How
    to
    overcome this Problem. I need to display it's
    Mutilple(a*b) value of "a " and " b".
    import java.io.*;
    class Mul{
    static int a=0;
    static int b=0;
    static int Count=0;
    public static void main(String args[])throws
    IOException{
    BufferedReader br =new BufferedReader(new
    InputStreamReader(System.in));
    do{
    a=(char)br.read();This line will get you the ascii-value of the typed character.
    This line will not get you the value typed in.
    Try looking for Integer.parseInt()...
    Count++;
    b=(char)br.read();
    if(Count==2)
    System.out.println("The Multiplied Value is "+a*b);
    }while(Count<2);

  • Get input from user and create a file and run a script in command line.

    Hi all,
    i'm trying to get a input from user and write it into a file named alpe.jacl
    To get multiple userinputs like address and jobtitle etc etc in the same single window.
    and the code will save the inputs in alpe.jacl one by one in a new line like
    nameis name
    address russia
    jobtitle dev
    So i coded like below.
    Though GUI for user input looks dull Its working fine.
    Now I want this code to perform one more task which is the GUI will contain one more button INSTALL with OK and CALCEL .
    and when after putting all inputs and creating the alpe.jacl file if someone clicks INSTALL it should start ./install.sh script present at the same folder which contains some unix shell commands.
    Here am not able to figure out how to go further...
    One more thing after all the inputs given when I am clicking on the OK button its closing the window instantly which i dont want. I want it like it should wait till someone press CANCEL to exit.
    Please some one help me.
    import javax.swing.*;
    import java.io.*;
    public class file
    public static void main(String []args)throws IOException
    FileWriter ryt=new FileWriter("alpe.jacl");
    BufferedWriter out=new BufferedWriter(ryt);
    JTextField wsName = new JTextField();
    JTextField sName = new JTextField();
    JTextField cName = new JTextField();
    Object[] message = {    "Web Server Name:", wsName,"Server Name:", sName,"Cluster Name:", cName};
    int answer = JOptionPane.showConfirmDialog(    null, message, "Enter values", JOptionPane.OK_CANCEL_OPTION);
    if (answer == JOptionPane.OK_OPTION){    String webserver = wsName.getText();
    String server = sName.getText();
    String cluster = cName.getText();
    out.write("set webservername " +wsName.getText()+"\n");
    out.write("set ClusterName " +cName.getText()+"\n");
    out.write("set ServerName " +sName.getText()+"\n");
    out.close();
    }}Thanks,
    Ricky

    Thanks a lot.
    Is there any way through which i can assign a scroll bar to my panel.
    As when the number of user inputs grows the GUI becomes more bulky and some of the fields are not showing up.
    Cheers
    _Ricky                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can i get input from user in Workflows

    Hello professionals,
    I'm new to SAP B1 Workflow, i have created some workflows and they all worked fine.
    But, I am wondering, How can i get input from user?. For example, i want to display list of options to choose between them and route the workflow based on the selected option. I don't want to use the exclusive gateway and check for some conditions, i want to get input from user.
    How can i do that?
    Thanks in advance,
    Kareem Naguib

    Hi,
    Please refer SAP help file:
    http://help.sap.com/saphelp_sbo900/helpdata/en/b8/1f9a1197214254b79bcf8f93f9fff9/content.htm?frameset=/en/44/c4c1cd7ca22…
    Thanks & Regards,
    Nagarajan

  • How to get input from card reader

    hi, everyone,
    I have a project, which needs me to get input from card reader. My terminal input is IBM POS system, but it didnot provide the API to get the input. How can I get the input? Need your help so much! and thanks a lot

    Now this is a wild idea.... how about searching the IBM site for technical information ?

  • How to Get Input from Command Prompt?

    How can i get input from command prompt like
    C:\
    or linux ?
    (Here's what I use now)
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String line;
    Whlie((line=in.readLine())!= null)
    { System.out.prinln( line) ; }
    IS THERE A BETTER WAY?

    The main method within a java class accepts command line input through a String array.
    In this example args is the String array. You can access the parameters as args[0] for the first parameter, args[1] for the second parameter, etc....
    The usage for the example below would be :
    c:\EDIFormat file1 file2
    Where args[0] would equal file1 and args[1] would equal file2.
    public class EDIFormat {
    public static void main(String[] args) {
              if (args.length < 0) {
                   System.out.println("No Parameters supplied. Exiting....");
                   // open input and output files
                   EDIFiles(args[0], args[1]);
    Hope that helps!

  • Read input from user and strore in ztable

    Hai,
        could you please give some examples of How to read the input data from user and store in Ztable.
    Thanks

    Hi Prasanna,
    If i understood your requirement correctly,
    The below code will insert record in DB table as soon as you enter the value in two fields and press enter button .
    Go through the below code,
    <b>In Layout</b>
    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    <htmlb:content design="design2003">
      <htmlb:page title = "first page ">
        <htmlb:form>
          <htmlb:inputField  id="field1"/>
          <htmlb:inputField  id="field2"/>
          <htmlb:button       id="submitButton"  text = "Press Me"
                              onClick       = "myClickHandler" />
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    <b>In Oninputprocessing event</b>
    CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
      DATA: event TYPE REF TO CL_HTMLB_EVENT.
      data : begin of wa,
             matnr type mara-matnr,
             ersda type mara-ersda,
             end of wa.
      event ?= CL_HTMLB_MANAGER=>GET_EVENT( runtime->server->request ).
      IF event->id = 'submitButton' AND event->event_type = 'click'.
        DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
        DATA: data1 TYPE REF TO CL_HTMLB_INPUTFIELD.
        data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
                                               name     = 'inputField'
                                               id       = 'field1'
        IF data IS NOT INITIAL.
         value = data->value.
          wa-matnr = data->value.
        ENDIF.
        data1 ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
                                               name     = 'inputField'
                                               id       = 'field2'
        IF data1 IS NOT INITIAL.
         value = data->value.
          wa-ersda = data1->value.
        ENDIF.
       insert into ZAZAZ_BSP CLIENT SPECIFIED values wa.
      ENDIF.
    Regards,
    Azaz Ali.
    Don't forget to reward points.

  • How do i get input from user?

    For example if i wanted to ask "Whats your favorite number" and then get the input from the user and assign it to a variable how would i go about doing that?
    Any help would appreciated

    hope this helps
    import java.io.*;
    public static void main(String[] args)
      //this is the important part
      BufferedReader in = new BufferedReader( new InputStreamReader(System.in) );
      String response = "";
      System.out.println("What is your favorite color?");
      try{
           //now read the line
           response = in.readLine();
      }catch(Exception e){
            //enter error code here
      System.out.println("I like " +response+ " as well!");
    }

  • How to valid inputs from user in module pool

    hi,
    i m using table control in module pool and in 1 of the table control fields i m using user defined F4 help which is getting filled from a internal table. if the user enters anything apart from the contents in my F4 help the record should not get saved and system should return error . how and where to put this validation?
    please help.
    thank you.

    hi,
    Write the code in PROCESS ON VALUE REQUEST in the Module pool Program ....
    PROCESS ON VALUE REQUEST
    FIELD <Field_name> MODULE <Module_name> ..
    Double click on this field then write the function moduel to get the Internal table values when the user press F4 on that field, after completing this check by pressing the F4, if it working fine then the Validation is automatically done by this POV ..
    if the USer enters other than the internal table values then the Error message will raised at that stage
    Regards
    Sudheer

  • How to get Portal Login User and Its Related BP in CRM?

    Hi,
    An ABAP Webdynpro program is called in CRM from Portal user by a portal link. How to get the user ID and its related BP in CRM? Thanks!
    The portal is integrated with ECC, and all users and BPs are maintained in ECC then replicated to CRM.
    Best regards,
    Hao

    Hi,
    Try the below code
    IUserFactory userfact=UMFactory.getUserFactory();
    IUser user=userfact.getUserByUniqueName(request.getUser().getUserId());
    String usrid=user.getUniqueName();
    And also you can get the groups assigned to user by using the below code
    Iterator groups = user.getParentGroups(true);
    while (groups.hasNext()) {
         String groupstr = (String) groups.next();
         IGroup g = UMFactory.getGroupFactory().getGroup(groupstr);
         response.write("Group name "g.getUniqueName()"<br>");
    Regards
    Suresh

  • How to get input from keyboard scanner into an array

    This is probably a very basic question but I'm very new to java..
    My task is to reverse a string of five digits which have been entered using keyboard scanner.
    E.g. - Entered number - 45896
    Output - 69854
    I used the StringBuffer(inputString).reverse() command for this, but i need a more basic method to do this.
    I thought of defining an array of 5
    int[] array = new int [5];
    and then using,
    Scanner scan = new Scanner(System.in);
    to enter the numbers. But I can't figure out how to get the five input numbers into the array.
    If I can do this I can print the array in reverse order to get my result.
    Any other simple method is also welcome.

    Hey thanks for the quick reply,
    But how can I assign the whole five digit number into the array at once without asking to enter numbers separately?
    E.g. - if entered number is 65789
    Assign digits into positions,
    anArray [0] = 6;
    anArray [1] = 5;
    anArray [2] = 7;
    anArray [3] = 8;
    anArray [4] = 9;
    I'm really sorry but I am very new to the whole subject.

  • JComboBox    How to get input from JComboBox

    Hi all.
    I have a JComboBox called combobox.
    User can choose one string out of 5 using this JComboBox.
    Whenever the user press a button, I'd like to get an input through this combobox using actionListener.
    How can I get input through JComboBox?
    combobox.getValue() ???
    I appreciate your help !

    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComboBox.html
    Object getSelectedItem()

  • How to sort data from database and display in combobox in required order

    Hi evrybody, it makes me sick i need to get data form database and fill combobox in required order (last item added to database - last firstName) actualy i already did that, but i'm useing DefaultComboBoxModel and all records are sorted in alphabetical order. Thanks very much for any help

    The items in the JComboBox are displayed in the order in which you add them to the combo box. Use an order by clause in your SQL statement.
    Don't [url http://forum.java.sun.com/thread.jsp?forum=54&thread=516608]crosspost.

  • How to get the column name and table name with value

    Hi All
    I have one difficult requirement
    I have some column values and they have given some alias column names but i need to find the correct column name and table name from the database.
    For example value is "SRI" and i dont know the table and exact column name so is there any possibilities to find the column name and table name for the given value
    Thanks & Regards
    Srikkanth.M

    Searching all the database for a word...
    Courtesy of michaels...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    11g upwards
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from (select column_name,
                   table_name,
                   'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
              from cols
             where table_name in ('EMP', 'DEPT')),
           xmltable (str columns result varchar2(10) path '.')
    TABLE_NAME                     COLUMN_NAME                    SEARCH_STRING                    RESULT   
    DEPT                           DNAME                          es                               RESEARCH 
    EMP                            ENAME                          es                               JAMES    
    EMP                            JOB                            es                               SALESMAN 
    EMP                            JOB                            es                               SALESMAN 
    4 rows selected.

  • Get data from view and displaying the table data into Excel  pivot table

    Hi All,
    I have a small reqirement inthat When i get the data from the View that would displayed as Excel Pivot table.
    For displaying gerneral data to Excel I have followed Binarcy cachey
    Please suggest me in this.
    Thanks,
    Lohi.
    Message was edited by:
            Lohitha M

    Try this:
    http://download-west.oracle.com/docs/html/B25947_01/bcservices005.htm#sthref681
    Specifically code sample 8-10 for accessing the AM object.
    Then use the findView method to get a pointer to the VO.

Maybe you are looking for

  • How to erase TM?

    I need to erase TM but don't know how. It doesn't appear in Disk Utility. I installed a new 1.5TB internal HD and made it my startup disk. I had no problems cloning the old startup disk(500GB) to the new one and everything works fine. The only proble

  • Protecting command-line arguments from glob expansion

    Hi. I am writing a java program and I want to pass it a regular expression as a command-line argument. However, when I use certain regular expressions (e.g. [a-z]*), the java command-line interpreter recognizes this a glob expression and replaces it

  • HT1711 How to download a song in high quality in Itunes?

    How to download a high quality song in itunes? because we got a system at school and the quality that i download is not good in skeakers.

  • Window 7 64 bit - sleep mode - PC won't wake up

    Accidentally put PC into sleep mode from start button. Power lite initially blinked. Moving mouse, hitting space bar or "sleep" key on keyboard does not work.  I held power button down for 5 seconds, and PC started beeping. Held power button down aga

  • Moving Black2 to a new computer

    Help, I am trying to move my existing (and loaded with data) Black2 to my new computer. The new computer is not seeing it, and neither is the WD Installation software.