User to enter values and stored as array

Hi,
I have some problem with my labs that I would like to clear by doubt.
I need a user to keyed in a list of age so to calculate the average age. The values entered is stored in into an Array (not arrayList) I have been using ArrayList rather than array. =(
So I have used a bufferedReader to capture the input the user keyed in. unlike arraylist, I could not create an array without knowing the size of it.
Also,
My following code has some proble, when I run the program and enter 99 as the first value input. The system would terminate. However, when I enter other values than 99, the system would not terminate. Do point out my brainless mistake. Thanks alot.
  public static void main(String[] args) {
         // TODO, add your application code
        int num =0;
         int j = 0;
  boolean stop = false;
          int[] arr = new int[200];
           BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
              while(stop == false){
           try {
         num =  Integer.parseInt(br.readLine());
      } catch (IOException ioe) {}
      if(num == 99){
      stop = true;
    arr[j] = num;
    j++;
    }

seah_ly wrote:
I need a user to keyed in a list of age so to calculate the average age. The values entered is stored in into an Array (not arrayList) I have been using ArrayList rather than array. =(Yes you are correct in using an ArrayList, however if arrays are required you could mimic the actions of a growing ArrayList by using an array and initializing a new array with double the size of the old array and copying the old elements to the new array. Note this is exactly what an ArrayList does.
My following code has some proble, when I run the program and enter 99 as the first value input. The system would terminate. However, when I enter other values than 99, the system would not terminate. Do point out my brainless mistake. Thanks alot.
if(num == 99){
  stop = true;
}What do you think this does to the while loop?
Mel

Similar Messages

  • Comparison between entered value and stored value

    An user enters his or her code, the code needs to match the code which corresponds to her code in the file, else the value is set to zero and asks to be re-entered, if correct to proceed.
    Attachments:
    hell.vi ‏63 KB

    And what is the problem?
    Using the constant seems to be working as you describe, is it when you read a file there is a problem? If so could you supply one such file?
    MTO

  • How to ask user to enter value in select statement

    Hi,
    Can anyone tell me syntax of select statement where i can ask user to enter value .
    for example i am trying to use belowthing but it displaying error
    select * from emp where empname=:empname
    SP2-0552: Bind variable "empname" not declared.
    2.Is there any data dictionary table to see all pl/sql procedures and corresponding code?
    Thanks,
    sri

    user632733 wrote:
    Can anyone tell me syntax of select statement where i can ask user to enter value .None. The SQL engine resides on the server. It is incapable of prompting for data entry on the client.
    The client interacts with the user. The client is suppose to:
    a) prompt for variable values
    b) send a SQL statement to Oracle
    c) bind values to bind variables in the SQL statement
    for example i am trying to use belowthing but it displaying error
    select * from emp where empname=:empnameIn SQL*Plus, you need to create a bind variable:
    SQL> var empname varchar2(200)
    And then assign a value to it:
    SQL> exec :empname := 'John Doe';
    Note that this is still not ideal - as the assignment is also done via the server and sends a PL block to the server. This block contains non-sharable code and this can lead to fragmentation of the server's Shared Pool.
    But it does illustrate the basic principle.

  • Powershell to create pop box which then creates a folder (with entered value) and sub folder with specific security

    Hi All,
    Complete novice to powershell would love some help to assist a new windows storage workflow I am implementing.
    I have a windows server 2012 file server (\\FS01) and projects share \\fs01\projects. 
    We use job numbers to create a project and name the folders with the job num (eg Job Num XX12345 , \\fs01\projects\XX12345)
    Then after each project folder is created we will create 4 subfolders underneath and specify the following rights to the following AD groups.
    Folder Name - AD Group- Permission
    Scoping - Project_Management -RW
    Delivery - Project_Management -R
    Finance - Finance- RW
    Assets - Creative - R
    I would like to create a script that lives in the route of \\FS01\Projects and when clicked a pop up box appears, the end users enters the job code  and then the script sets up the folder with the entered value and creates sub folders with the referenced
    AD groups and security.
    Any help would be awesome!
    Sammy

    Start by learning how to write PowerShell scripts.  What you are asking is a whole complex list of requirements.  This is a forum and not free consulting or training.
    Workflows are complex beasts that require a good knowledge of PowerShell.  Now is the time to start your training.  I recommend starting with a good book and taking your time learning PowerShell step-by-step.
    ¯\_(ツ)_/¯

  • Do u know how to prompt user to enter password and validate the password?

    hi all,anyone knows how to prompt user to enter password and validate the password as well?I do not need the GUI.Can someone post the codes here?Thanks!

    hi all,anyone knows how to prompt user to enter
    password and validate the password as well?I do not
    need the GUI.Can someone post the codes here?Thanks!Codes are
    BufferedReader
    System.in
    if
    else
    System.out.

  • Popup screen with two check box and a text area for the user to enter value

    hi,
    i have a requirement when a button is clicked a popup screen should appear with two check box and a text box where the user can enter a value.
    is there any function module which has that functionality

    Hello,
    You can create a new screen and select the screen type as <b>model dialog box</b>.This will give you a<b> pop-up screen</b> and you can call this model dialog box screen in the PAI of the screen where the button is present.(At user-command).
    <b>case ok_code.
    when 'BUTTON'.
    call screen 200 starting at 10 10.</b>
    You can design the PBO of this pop-up screen as per your needs.
    Regards,
    Beejal
    **Reward if this helps.

  • Forcing user to enter values at table level

    Hi,
    I have created a table ztest. How to force user to enter the values for certain fields in the table which are not keys, similar to not null in RDBMS. selecting the initial values filed in SE11 populates with some default value, but it doesnt force the user to enter the value.
    Regards,
    Raghu

    Hi,
    Just check out transaction code SE54 for events.
    Go in SE54.
    Give your table name.
    Go in Environment --> Events.
    Here add the Event '01' i.e. Before saving the data.
    Give the name for event eg 'BEFORE_SAVE'.
    Click on Editor to create an include program.
    In the include program write
    form before_save.
      data: f_index like sy-tabix. "Index to note the lines
      loop at total.
        if <action> = 'N' or <action> = 'U'.
          read table extract with key <vim_xtotal_key>.
          if sy-subrc eq 0.
            f_index = sy-tabix.
          else.
            clear f_index.
          endif.
          "(make desired changes to the line TOTAL)
          "End of Modification.
          modify total.
          check f_index gt 0.
          extract = total.
          modify extract index f_index.
        endif.
      endloop.
      sy-subrc = 0.
    endform.
    Note here in field symbol 'Total' your workarea will be their. You can make necessary checks here.
    Or else you can go for making a custom transaction for your requirement.
    Regards,
    Nitin
    *Mark all helpful answers

  • How to stop user from entering value for already existing data

    Hi ,
    We have a situation , where we need to give user a template for entering the data and then send it to the database. But we want that if user has already entered the value for a combination, then he should not be allowed to select the same combination again in that template.
    In other words , there should be write access but not update access.
    So I have two questions related to it:
    1. How to build report with giving user , the drop-down list of available members under each dimensions. (I know that we can provide list by writing all of them in excel and then using those values in drop-down)
    2. How to restrict the user for selecting the combination which has already been selected.
    Need your suggestion
    Thanks
    Sanjay

    Hi Sanjay,
    for your first question...
    you can build an EVDRE in a hidden area/sheet to display all values of a desired dimension in rows. Set Option SuppressDataCol to 'Y'. Also maintain MemberSet options to display only the values you need.
    Now you can reference your DD-box to the key- or description range.
    With some VBA-code you can refresh this EVDRE on Workbook_Open and also set the range (attribute ListFillRange?) of you DD-box dynamically to the RowKeyRange.
    Hope, it helps.
    Regards
    Steve

  • Looping and storing into arrays

    Anyone managed this yet, or BC team - you got any thoughts....?
    There could be cases and situations like this one and in this case either a solution or just having a loop array filter would be nice also...
    Issue:
    You have a web app with classifications. You want to people in a company. You want to show board members (Classification) in one section and the rest of the team in another.
    The Rest of the team will show the board members because you do not have classifications in list view.
    Solution 1:
    BC to provide classifications in list view liquid/collection
    Solution 2: (And something we probably may need too)
    It would be great to loop through a collection and store into an array
    {% assign myarray = [] -%}
    {module_webapp collection="myitems"}
    {% for item in myitems-%}
         {% myarray | map: item.name-%}
    {% endfor -%}
    {{myarray}}
    It would be handy to be able to store items in an array. You can already map an array, have a manually made array you can loop through, have a string you map into an array via a cookie etc.

    Well Rob, you have {module_data... So if you want to go even further You can turn to that and you can defiantly do the where. I think bringing that to all modules would be some serious overkill work, you would be basically replicating that functionality.
    That is how I am classing _data - This is your hardcore module to use when you want to do some serious s*** but as I have said in other threads, We should not be turning to that all the time when we just need something like categories in list view. That would also be over kill in those situations.
    But then when you do use _data it would be good to get some results, map it to an array and then use that for something else.

  • Problem  to Multiply the Values and Stored in the Same Datatype Variable.

    HI,
    my Variables are :
    data : lv_per    TYPE konv-kwert,
              lv_amt    TYPE KONV-KWERT,
             lv_cost    TYPE KONV-KWERT.
          LV_COST = 2073.00.
          LV_AMT   = 6000.00.
        I want to calculate as lv_per  = (LV_COST /  LV_AMT)  * 100.
        BUT Value coming as 0.00 in lv_per instead of coming correct result as 34.55.
    Kindly Help me on the same.

    Hello Mahender,
    This is definetly problem of fixed-point arithmetic check box. So in which ever main program you are going to include this you
    can set FPA check box in it's attribute screen.
    Thanks,
    Augustin.

  • Force a user to enter a value for a parameter.

    Hi,
    I have a report with a bunch of parameters and I want to force the user to enter values for two parameters amongst all of them. Like for example when the user doesn't select values for those 2 parameters he should get a dialog box saying "please enter value for xyz parameter" or something like that, which will force the user to enter a value for the parameters before he can see the report.
    Please let me know if BI Publisher can do this.
    Thanks,
    DY

    Thanks for your replies BIPUser. I have recently started working on BI Publisher without a lot of help around.
    The information in the link is what I was thinking of, if there is no such feature I'll have a default value for those 2 parameters.
    Thanks,
    DY

  • Set the user entered values to context node

    Hi Experts,
    I am using a context node for 'BuilHeaderSearch' BOL entity and have provided first name, lastname and email for the user to enter values to search the BP. My requirement here is to capture the values entered on the UI screen and set to context node which supposedly should be taken care by SET_* methods, which is not happening at the moment, consequently are not set to context node meaning that it doesn't go to SET_FIRSTNAME method.
    I know i could access the values using formfields but i don't think that's recommended.
    Please give me some clue.
    Many Thanks for sparing your valuable time,
    Santosh

    Hi Santosh,
    I think i got the problem now..
    Always create instance creates a entity if there is no entity exist in the collection of the context node, for eg lets say you are trying to create one model context node2 which is related to any existing parent context node1.. In this scenario if you check always create instance for the dependent context node2, it will create the blank entity and this you can varify in the  on_new_focus of the dependent context node2.(Create related entity code will be there which will create a blank entity if you have check always create instance).
    If you don't specify always create instance, framework will not create blank entity for your context node(Check the on_new_focus code no create_related_entity code will be there).
    In your requirement if you don't select "always create instance", then as per my understanding you will not be getting blank entity and set_property call should result into exception, which will not be the case when you have entity thru always create instance.
    Hope i am albe to clarify this..
    Cheers,
    Sumit Mittal

  • How to restrict user to must enter value in compulsory fields

    Greetings !
    I had a personal information form. I want to restrict user to enter values in all fields e.g Compulsory fields (Username, D.O.B etc)
    how i restrict user to must enter value in Compulsory fields

    I created an example on apex.oracle.com
    http://apex.oracle.com/pls/apex/f?p=18686:1:0:::::
    like you see a red staric placed on ID it means it is complusory to enter because it is a primary key, i want this on every field or to restrict user to enter all data , if any field left blank it will give error "to Fill respective field ", but not on creation but on left blank (if user type ID e.g 12 and skip ename field and go on Job field it gives error to fill Ename first)

  • Et_validate doesn't fire if user changes value and presses update button

    I am maintaining a flag for "dirty" records in a potentially large number of rows in a matrix. To set this flag I check for the et_Validate event and ItemChanged = true. This works fine if the user changes a value and then presses tab to leave the field.
    My problem is that et_Validate does not fire if the user changes a field's value and then presses the update button.
    It's like the screenpainter where if you change a field's value and then select a different field before pressing tab your change isn't saved.
    I suppose I could always send a tab keypress or automatically update the current row but I'm wondering how others handle this.
    I am currently using SBO2005A SP1 PL11.

    Additional info:
    If I change a matrix cell and click on the update/ok button then the ItemEvent.row = -1 and the active item is still the matrix. If I force a "click" in a field on the first row then the et_validate fires otherwise it does not.
    Does anyone have any other ideas on forcing et_Validate to fire when the user clicks on a button?

  • Restricting user to exclude values in selection screen

    Hi Everybody,
    I am facing a problem with f.m SELECT_OPTIONS_RESTRICT.
    I want to restrict user, so that he will only be able to exclude values (single, multiple or range) from a selection-option.
    The code snippet is as follows:
    item messages -> restrict selection
      opt_list-name = 'EXCLUDE'.
      opt_list-options-ne = 'X'.
      opt_list-options-nb = 'X'.
      APPEND opt_list TO restrict-opt_list_tab.
      ***-kind = 'B'.
      ***-name = 'A2'.
      ***-sg_main = 'I'.
      ***-sg_addy = ' '.
    ***-op_main = 'EXCLUDE'.
      ***-op_addy = 'EXCLUDE'.
      APPEND *** TO restrict-***_tab.
      CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
        EXPORTING
        PROGRAM                      =
          restriction                  = restrict
        DB                           = ' '
        EXCEPTIONS
         TOO_LATE                     = 1
         REPEATED                     = 2
         SELOPT_WITHOUT_OPTIONS       = 3
         SELOPT_WITHOUT_SIGNS         = 4
         INVALID_SIGN                 = 5
         EMPTY_OPTION_LIST            = 6
         INVALID_KIND                 = 7
         REPEATED_KIND_A              = 8
         OTHERS                       = 9
    But this is only including the single multiple and range value. Can anyone throw some light on it?
    Thanks
    Samit

    I took a look at the documentation of this FM to confirm what I was thinking:
    "You can also disable the function allowing users to enter values to be excluded from the selection (SIGN = 'E')."
    So I think this is trying to tell us that we can turn off the ability for the user to enter "exclude" but we cannot turn off the option for the user to enter "include" options.
    When you set ***-sg_main = 'I', it means that only "include" options are allowed.
    I think you will need to do your own validation.
    In the event AT SELECTION SCREEN you can do a LOOP on your selection option name and validate the users selections:
    LOOP AT SO_MINE.
      IF SO_MINE-SIGN NE 'E'.
        SET CURSOR FIELD 'SO_MINE-LOW'.
        MESSAGE E123.
      ENDIF.
    ENDLOOP.
    It has been awhile since I used this FM so please let us know how it goes.

Maybe you are looking for

  • Problem while sending fax through a SAP Smart Form

    Hi, I am trying to send fax through a smartform but it is not working, please see the details below. I am calling the Function Module "SSF_FUNCTION_MODULE_NAME" in a PAI event.  After storing the FM name "/1BCDWB/SF00000029"in a local variable "ls_fr

  • Check in migo while gr raw material should equal with the challan materials

    hi friends, while doing gr in migo there should be a check for  the raw material's which we are giving should match with challan materials. Here challan no is entered at the excise invoice tab- subcontracting challan level. points will be rewarded, t

  • .psd thumbnails

    How can I view the thumbnail picture on a .psd file in CS6.  All I get is a blue box with psd/PS on it instead of the picture that's on that file.  This is very annoying because if I'm looking for a specific .psd file I have to look on my picture vie

  • What is your email address

    I have sent my request to top up using my new credit card but it is still pending.I wanted to top up only once (US$10) but many are udner pending.How can I top up only once out of all pending and why is it still pending?I need to top up only US$10 an

  • ICloud folder query

    This should be simple but it's driving me crazy. I have set up iCloud folders for my iPhone and iPad. I have disabled the syncing facility as I know that if I delete photos on my iPhone then it deletes them on iCloud also. However, the files only app