Finding the right words

if i create a string array
String lists[3] = { "code1---apple", "code2---apple", "code3---apple"};
when the user asking for input , he type in code1
it will print out "code1---apple" line.
how to compare the user input with the array and print out the code1---apple line?

hi...
by using arrays you could set up 2 arrays, 1 for the code and 1 for the data where each data string corresponds to it's code...for example
String codes[] = {"code1", "code2", "code3"};
String data[] = {"apple1", "apple2", "apple3"};
after getting the input code from the user you compare it to each element in codes[] until you find code that the user entered...you can initialize indexOfCode to -1 to see if a code was found or not...for example
String input = //input form user
int indexOfCode = -1;
for(int i = 0; i < codes.length; i++)
if(input.equals(codes)
indexOfCode = i;
break;
now that you have the indexOfCode the same index of data[] will correspond to it's related code...so, to print out the code and it's data you could do this....
if(indexOfCode != -1)
System.out.println(codes[indexOfCode] + "---" + data[indexOfCode]);
hope this helps you..

Similar Messages

  • Here's how to find the right word in a string

    I needed to find the rightmost word in a string. I didn't find a simple formula in these forums, but I now have one, so I wanted to share it. Hope you find it useful.
    Assuming that the string is in cell A1, the following will return the rightmost word in the string:
    RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1," ","*",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))

    I found the problem. Whatever character was being used in the substitution was parsed out by the forum parser. I replaced it with "œ" (option q on my keyboard).
    =RIGHT(A1,LEN(A1)-FIND("œ",SUBSTITUTE(A1," ","œ",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))
    Still needs an error check for a single-word "sentence" and to remove the trailing period but it does seem to work. Pretty slick.
    Message was edited by: Badunit
    I see below that the problem was fixed by the OP.
    Message was edited by: Badunit

  • I have my download content code for the new Mountain Lion, and the printed instructions tell me to open the App Store select 'Redeem" in the quick links, enter my code. The problem is I cannot find the "Redeem" word in the quick links?  Where and why does

    How do I find the REDEEM word in the quick links section of the Mac App Store?  In fact I cannot find the quick Links either?

    Click the Featured tab, and look on the right hand side...

  • How to find the right bapi.....

    Hi everyone!
    I'm having trouble in finding the right bapi for my program. I'm looking for a bapi that will create a sales order with reference to quotation no. and it seems dat, i dont have any background in bapi.. can someone help me to do this job? Can someone provide the right code for this problem? Thank you in advance..helpful reply will be given enough points..
    Regards,
    Mackoy

    <b>To find a BAPI:</b>
    Go to SE37.
    Click on F4 in the input field.
    go to Information Systems.
    In the Function module name type keyword and press enter.
    You will get a list of all the FMs containing that key word.
    From these search the one you think is appropriate for your requirement.
    This will be helpful in finding BAPIs/ FMs in future.
    Regards,
    Sonal
    <b>Reward points if helpful</b>

  • Finding the right computer

    I'm not that knowledgable on laptops and I'm looking to purchase one where do I start?

    Credit goes to an Author by the name of Paul Tansey on BestBuy.com  for creating this buying guide:
     Laptop Computer Buying Guide
    By Paul Tansey  
    There's no way around it: you need a computer at home. Computers make it so easy to stay in touch, stay organized, entertained and informed, it's a wonder we ever did without them.
    With laptop technology advancing in leaps and bounds, there's no reason you can't take this power and convenience with you wherever you go, considering you can stay connected wirelessly just about anywhere these days. And most laptops can do anything a desktop can do, without the bulky tower and without forcing you to stay indoors. So just because you're working doesn't mean you can't work in the park!
    There are about as many different kinds of laptops out there as there are ways to use them, so let's look at some key points that will help you decide which one is right for you.
    If you want the basics...
    Choose a model that has the features you need to everyday computing. Not for making crazy rocket science calculations or memory eating applications, but to do the things that make life easier, like e-mail, Web browsing and word processing.
    Most models come with wireless capability, so you can grab a seat in any wireless Internet hotspot and surf to your heart's content.
    If you travel a lot...
    Many newer laptops are thinner and lighter than ever but still deliver heavyweight performance, packing all of the processing power, hard drive space and versatility you want into a thin frame that weighs less than 4.5 pounds. You'll pay a little more for the thin and light, but if you have to carry your laptop around with you wherever you go, you'll very quickly appreciate leaving the extra bulk behind.
    If you're big on home entertainment, photos and music...
    These top-end models feature big widescreen displays enhanced for crystal-clear, smooth video playback. The video cards, processors and operating systems are also enhanced for high-performance video and audio, with Media Center models featuring personal video recorder (PVR) capability, a built-in TV tuner, surround sound and multiple digital and analog video inputs.
    PVRs will change how you watch TV. Pause and replay live TV, then skip back to the live feed when you're ready. You can also program your laptop to automatically record your favorite shows.
    For your always-growing collection of images and music files, there are models that feature faster processors, more RAM and larger hard drives. They are also enhanced for displaying photos, and you have more options for getting your media into the computer, including additional USB slots and built-in memory card readers to swap images straight from your digital camera or other device.
    If you're all business...
    Professional Series laptops meet the demands your business requires whether you're working from home, in the office or on the road.
    Since your laptop is your business, look for enhanced security features like a fingerprint reader, which allows only authenticated users to access it, and an encrypting file system to allow for file and folder encryption at the user level. Some include motion-sensing hard drive protection that safeguard the laptop's hard drive against damage from a sudden movement or drop - important to consider when going from meeting to meeting.
    If size matters...
    Laptops come in all shapes, sizes and weights. Many are now an inch thick or less, with absolutely every millimeter of internal space used efficiently. These thin laptops don't lose a step compared to their beefier competition, with just as much processing power and a screen size and keyboard that won't leave you feeling shortchanged.
    As laptops get a little larger, the size of the screen also climbs. You can find high-performance Thin Film Transistor (TFT) LCD screen sizes ranging from 4.5" to 17" or more, most set up as widescreens.
    If you prefer wireless freedom...
    Nearly all laptops are capable of working wirelessly, with wireless cards and processors enhanced to perform when you're connected at a hotspot. Many laptops now include Bluetooth wireless for easy, safe, secure linking with a wide range of other devices, from handhelds to cell phones to wireless headphones.
    Instead of confining yourself to your office or den, or inflicting a tangle of wires and computer components on your décor, you can set your family up with a network of wireless laptops. Everyone gets the access they need, when and where they want it. Plus, if you need your computer for work, you can take everything with you and not worry about leaving a file behind or denying anyone their computer time.
    Multiple users can go online at once, and all of the same access protection can be installed to keep your kids away from online dangers. You can all use one central wireless printer and scanner for total convenience.
    If performance is key...
    Processing power can separate the handy from the incredible, so if performance is key, look for more processing power. Most processors will fall within the range of 1.0GHz to 3.0GHz, but different types of processors excel in different ways.
    The Intel lineup starts with the Celeron® M, while the Pentium® Dual Core is peppier and more powerful. The top-of-the-line Centrino® chipsets feature Core™, Core™ Duo and Core™2 Duo processors with built-in wireless capabilities, improved power-saving capabilities and enhanced performance.
    AMD also has a good range of processors. The AMD Turion™ 64 X2 and Turion™ 64 mobile technology is similar to Centrino® and adds wireless performance to their high-end processors with some supporting Bluetooth technology.
    RAM is also an important performance factor and serves as the real-time memory that makes your applications run faster and makes it possible to work with huge files. RAM starts at about 512MB, but most models can be upgraded with extra memory. You can find some that can be upgraded all the way to 4.0GB, which comes in handy for demanding multimedia applications.
    Many of the higher-end models will also include a generous amount of RAM built into the video card for smooth performance, especially for today's advanced 3D games.
    Drives
    Hard drive sizes vary considerably, from about 60GB (more than enough for basic computing needs) all the way up to 240GB, ideal for multimedia, home entertainment and games. Faster hard drives (measured in RPM) are better for quick access to data and for smooth video and game operation.
    Optical drives - The DVD/CD drive is at least capable of reading DVD-ROMs and burning CDs, but more and more can now work with rewritable DVD±R/RW and even double-sided or double-layered DVDs. If you need better performance, look for write speeds in the range of 24x for CD and 8x for DVD.
    Increasing the cool factor, optical drives on some HP computers are outfitted with a technology called LightScribe, which can burn a professional-looking label right onto your disc.
    The softer side
    The operating systems you can choose from will also impact performance, and will often include software to work with photos, multimedia or even TV.
    Windows Vista features Windows Media Center, a multimedia powerhouse that lets you watch your favorite shows, enjoy prized photos and manage your music. In addition, Windows Vista has numerous enhanced security features, new interface elements and increased mobility for working with other users or devices.
    The Apple® Mac OS X 10.4 Tiger also delivers great multimedia and networking performance and comes bundled with photo, music and moviemaking software.
    Staying power
    Battery life is also a consideration. Many manufacturers have been working to improve the efficiency of their systems to extend the amount of work you can accomplish per charge. This will come in handy on long trips or when you have to finish a project but can't find anywhere to plug in, like when you're on a park bench or a coffee house patio.
    Accessories for protection and convenience
    First and foremost, a laptop case will not only make it easier to carry around your computer and its related accessories, but it will also protect your investment. Laptop cases range in size, with some designed for style and others for capacity, and many for both.
    A small laptop mouse will give you a welcome break from your current pointing device, making it easier to navigate your screen. They come in either wired or wireless versions. An extra power adapter - one in the bag and one for the office - and back-up battery are also a good idea, so you never get caught without power.
    A flash drive that plugs directly into a USB port is an inexpensive and efficient way to transfer files. Pop one into your laptop case.
    With a better understanding of what separates a good laptop from a great one, it's easy to find the right one for you.
    Shop our current selection of laptops or check out our Laptop Finder. 
    *******DISCLAIMER********
    I am not an employee of BBY in any shape or form. All information presented in my replies or postings is my own opinion. It is up to you , the end user to determine the ultimate validity of any information presented on these forums.

  • Type the right word - program trouble

    Hi guys,
    I am trying to write an application that terminates the loop when the user inputs the right word. I have achieved that but i have 1 problem. First let me show you what i wrote so far.
    import java.util.Scanner;
    public class RightWord {
         public static void main(String[] args){
              Scanner input = new Scanner(System.in);
              System.out.println("Type in the right word");
              String str = input.next();
              str = str.toUpperCase();
              while(!str.equals("END")){
                   System.out.println("Try again, please: ");
                   str =input.next();
                   str = str.toUpperCase();
              System.out.println("Success");
    Now i have 1 problem and i need a suggestion for something else:
    1. When ever a user types in END the loop should terminate and it should print out Success, but if the user writes the end or anything else before or after END the loop terminates. What do i do so that the loop terminates only if just END is typed? I hope i am clear about this.
    2. Now i need a suggestion or a sample on how to save the number of times that a user wrote ND (not END, just ND) and after the loop is terminated, it should output: Success and The number of times the user typed ND is: x.
    Please advice.

    Eduu wrote:
    1. When ever a user types in END the loop should terminate and it should print out Success, but if the user writes the end or anything else before or after END the loop terminates. What do i do so that the loop terminates only if just END is typed? I hope i am clear about this.If you read the docs for Scanner.next(), you'll see that it reads the next token, which is roughly the next word, and since you're always just processing the result of next(), clearly, if any word on a line is "end", then that meets your terminating condition. What you want is if a whole line is equal to "end". Look at the docs for the Scanner class and see if you can find something that will help you there.
    2. Now i need a suggestion or a sample on how to save the number of times that a user wrote ND (not END, just ND) and after the loop is terminated, it should output: Success and The number of times the user typed ND is: x.Create a variable. Initialize it to zero. Every time ND is entered, increment it by 1.

  • I have a iphone 4s with ios 8.3 and I used to be able to sync only a week or two of emails from outlook email.  Now it won't let me do that and it syncs all my inbox.  How can I change it back to sync less.  I can't find the right place.

    I have a iphone 4s with ios 8.3 and I used to be able to sync only a week or two of emails from outlook email.  Now it won't let me do that and it syncs all my inbox.  How can I change it back to sync less.  I can't find the right place.

    I understand, as that was the place I would change it before 8.3 but now that option of Mail Days to Sync is not available?  Any idea why that would be?

  • How can I get a search bar added to my email archives screen to make it easier to search for the right archives folder, Samsung has one so I was surprised to see that I have to scroll up and down to find the right folder?

    How can I get a search bar added to my email archives screen to make it easier to search for the right archives folder, Samsung has one so I was surprised to see that I have to scroll up and down to find the right folder?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    You can modify the pref <b>keyword.URL</b> on the <b>about:config</b> page to use Google's "I'm Feeling Lucky" or Google's "Browse By Name".
    * Google "I'm Feeling Lucky": http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q=
    * Google "Browse by Name": http://www.google.com/search?ie=UTF-8&sourceid=navclient&gfns=1&q=
    * http://kb.mozillazine.org/keyword.URL
    * http://kb.mozillazine.org/Location_Bar_search

  • How to find the exact word in a long text?

    Hi,
    Scenario:
    I have long text containing the system status of the equipment.
    Issue:
    I need to find the exact word from the list of the statuses. I have tried to use the FIND keyword but it does not work for all the cases.
    Example:
              FIND 'REL' IN <status_list> IGNORING CASE.
              if sy-subrc = 0.
              " do something
              endif.
    If the status list contains the word 'RELR', the sy-subrc is set to 0 (which may be because it searches the list based on a pattern) but I want to get the exact match.
    Can anybody suggest me on this.
    Regards
    s@k

    >
    siemens.a.k wrote:
    > Dear Kiran, Vasuki,
    >
    > The data type of status list is char with length 40.
    > The status list:
    >
    > Case 1: list -  REL  MANC NMAT PRC  SETC
    > FIND 'REL ' IN <status_list> IGNORING CASE
    > the sy-subrc is set to 0
    >
    > Case2: list - CRTD MSCP NMAT PRC  RELR SETC
    > FIND 'REL ' IN <status_list> IGNORING CASE
    > the sy-subrc is still set to 0 even though the list does not contain the word 'REL'
    >
    > I have also tried using
    > if <status_list> CS 'REL'
    > and
    > if <status_list> CS 'REL '
    >
    >
    > Please do let me know if I am anyway unclear about issue...:)
    >
    > Regards
    > s@k
    This is becacuse when you check
    > Case2: list - CRTD MSCP NMAT PRC  RELR SETC
    It is having RELR so that is the reason you are getting subrc = 0.
    >Ok try CS it should work perfectly.
    It seems... CS also not the correct answer
    (It will count RELR)  below thread sachin is correct ...Do that way ....
    Regards
    sas
    Regards
    Sas
    Edited by: saslove sap on Jan 25, 2010 6:58 AM

  • HT1443 I need to upgrade from 10.5.8 to 6.0 or better to use a new HP wireless printer.  How do I find the right item to download?

    I need to upgrade from 10.5.8 to 6.0 or better to use a new HP wireless printer.  How do I find the right item to download?

    There is no download; you need to buy a Mac OS X 10.6 DVD.
    (83218)

  • Finding The Right App

    im having trouble finding the right app for my ipad. i will spend money and everything, but there are just no good apps out there. the type of app i want is a creation app, sort of like google sketchup, or even better, something like cinema 4d. ive never seen any app come even close to anything like that. i just like making and designing things. i play the game "Soundrop" alot because you just simply create lines into creative little structures and paths for the balls to bounce. if they ever came out for a line rider for the ipad i would probably pay $50+ just for that one app which already exists on the iphone but sadly not on the ipad...does someone have any suggestions for any apps that you think i would like?

    if they ever came out for a line rider for the ipad i would probably pay $50+ just for that one app which already exists on the iphone but sadly not on the ipad
    Sure it is. $2.99
    -> Line Rider HD

  • HT4539 I have 2 year old I-phone 4 that has never been updated. I need to download an update from my computer but can not find the right place on the I-Tunes page. Do you know where is the right place to update a phone that does not have an "update" butto

    My (old, never updated) I-phone has no "update" button in Settings and I would like to update it. I can not find the right place on I-Tunes to download the updates. Do you know where to look?

    Update your iPhone, iPad, or iPod touch - Support - Apple

  • How to find the right kstat info & interpret it ?

    Having found out how to read the kstat structures I am
    still struggling with finding the right information which
    makes sense!
    I am interested in the following statistics:
    0. Swap Space - similar to that reported by swap
    1. Scan rate similar to that reported by vmstat
    2. Handspread page (see Adrian Cockcrofts' performance monitoring articles)
    3. Disk Space Usage - similar to df -k
    4. Process memory usage -- ps
    5. System Error Messages -- this may not be possible to read at all
    from kstat. Probably here I will have to make do with reading /var/adm/messages
    6. Disk Errors -- similar to iostat -E (Solaris 2.6 onwards)
    7. Ethernet stats -- like netstat -I le0
    I found the following article on SunSolve Online: FAQ 1230 'Three Virtual Memory Performance Monitors' which directs me to some of the kstat cell
    types.
    I started with swap space. The above article plus a few other pointers seemed to indicate the the
    correct kstat struct and field to use here was vminfo.swap_avail
    When I compared the figures dumped from this structure with those reported by vmstat & swap they
    did not compare! eg.
    kstat: vminfo.swap_avail 321393372929
    kstat: vminfo.swap_free 33339822544
    vmstat unix tool:
    swap avail (KB) 19932
    Furthermore sysinfo.h indicates that vminfo.swap_avail is expressed in pages.
    1 page = 4.096 KB, so the kstat figures should be multiplied by 4 which makes
    the comparison even worse. Whilst I don't expect the figures to be
    an exact match -- I was hoping they would be in the same ball-park,
    Next I tried page in/page out rate
    Here I compared:
    kstat: cpu_vminfo.pgpgin 473224
    kstat: cpu_vminfo.pgpgout 14554
    vmstat unix tool:
    pi (page in) 4
    po (page out) 0
    These figures sort of match up, if you take the most sig digit in
    vminfo.
    I was wondering if anyone has a definitive list on what are the best
    kstat fields to use -- and if any wierd and wonderful calculations must
    be performed on any of them to get figures close to that supplied by
    the familiar unix tools.

    Hi!
    I wrote a quick program to read the vminfo stats and like you saw completely crazy figures. I looked further into this and found that every second, the system clock routine adds the freemem, swap and so on to a cumulative total.
    To put it another way, the figure you see for free memory is the sum total of the value of freemem sampled every second since your system booted.
    Thus, to get the average freemem in pages since boot, you need to read the value of freemem and divide by the number of seconds since boot.
    You can derive the number of seconds in two ways from the kstats:
    (1) read lbolt (incremented every 100th sec) and divide by 100 (hz)
    or (2) read sysinfo.updates (which is incremented every time the kstats are updated).
    I have attached a sample program that demonstrates both of these and reports average freemem since boot in K (like vmstat).
    Similarly, to get a 5 second average, take two readings of freemem and sysinfo.updates five seconds apart , then calculate
    (freemem2-freemem1)/(updates2-updates1)
    It seems most, if not all, of the system counters are cumulative in this fashion.
    Hope that helps.
    Ralph
    SUN Developer Technical Support
    <pre>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <kstat.h>
    #include <sys/types.h>
    #include <sys/time.h>
    #include <sys/sysinfo.h>
    #include <stdio.h>
    main()
    kstat_ctl_t *kc;
    kstat_t *vminfo_ksp;
    kstat_t *system_misc_ksp;
    kstat_t *sysinfo_ksp;
    kstat_named_t *lbolt_knp;
    vminfo_t vminfo;
    sysinfo_t sysinfo;
    int hz;
    int ltime;
    ulong_t updates;
    if ((kc = kstat_open()) == NULL)
    perror("kstat_open failed"); exit(1);
    /* get lbolt and divide by hz to get secs since boot */
    system_misc_ksp = kstat_lookup(kc, "unix", 0, "system_misc");
    kstat_read(kc, system_misc_ksp, NULL);
    lbolt_knp = kstat_data_lookup(system_misc_ksp, "lbolt");
    hz = sysconf(_SC_CLK_TCK);
    ltime = lbolt_knp->value.l/hz;
    /* get number of statistic updates so far (=secs since boot) */
    sysinfo_ksp = kstat_lookup(kc, "unix", 0, "sysinfo");
    kstat_read(kc, sysinfo_ksp, &sysinfo);
    updates=sysinfo.updates;
    printf("lbolt time %d\n",ltime);
    printf("updates %d\n",updates);
    /* get vminfo */
    vminfo_ksp = kstat_lookup(kc, "unix", -1, "vminfo");
    kstat_read(kc, vminfo_ksp, &vminfo);
    printf("freemem %lld\n",(vminfo.freemem*4)/updates);
    printf("freemem %lld\n",(vminfo.freemem*4)/ltime);
    </pre>

  • Finding the right htmlBusiness page

    Hi,
    we are on WAS 700 with internal ITS.
    I am dealing with SRM EBP templates and I can't find the right htmlBusiness source .
    From the html source code of the page rendered in the webbowser I get the info that my page is
         <!--
    This page was created by the
    SAP Integrated ITS, WebAS: EBT, workprocess: 2
    All rights reserved.
    Creation time:  Wed Oct 31 12:00:57 2007
    Charset:        iso-8859-1
    Template:       bbpsc02/99/saplbbp_sc_ui_its_100.html  -->
      <!-- No session management -->
       <!-- Domain relaxation already done -->
    <!-- START:  GENERAL DATA                         : Template   100 -->
    Looking at it in the ABAP Workbench I can find an entry which seems to be responsible for the peace of source I have to change - its a subscreen:
    <b>Look at this:</b>
    <!--  SUBAREA:     ACCOUNTING    ------------------------------------------------ -->
    `if (gs_screen-subgeneral-EXT_SCR_TYPE.value == "ACCO")`
      `BBPXBoxBegin(TITLE-ACCOUNTING.label, BTN_SUB_GENERAL_CLOSE.okcode )`       
        `includeFrame (~frameName="gc_sub_general")`
      `BBPXBoxEnd()`
    `end`
    The Dynpro 100 infact has a subscreen called gc_sub:general.
    <b>The Question is:</b> Where do I find the html Version for the subscreen. It includes icons, which I need to replace.
    I notice that there is  this function BBPBoxBegin which might also be responsible for my source. Didn't find it yet, either...
    Thanx a lot,
    Matthias

    Sorry - just found the source - it is in the BBPXBox function, which I just found...
    thanx anyway, kind regards, matthias

  • Finding the right harddrive?

    Hi!
    I am trying to find the right HD to swap with my current 160GB. The criteria are simple. At least 500GB and 7200 RPM.
    However I don't know which are compatible. I have a 15" MacBookPro (ver. 2,2) 2,16 GHz Intel Core Duo 2 from January 2006, with 4 GB Ram installed. I wan't to make a clean install with Snow Leopard once the disk is up and running. But which to chose. It seems there are a lot of problems with the Seagate Momentus so I was looking at this one:
    http://www.edbpriser.dk/Product/Details.aspx?pid=667834
    Is that a good choice?

    hitachi? eeek!
    on your machine, the 7200rpm drive won't make much, if any difference, due to that mac only being SATA I. between the density of the 500gb disk & the bottleneck on the sata bus, the rpm difference isn't a factor...
    so don't worry about getting a 7200 drive. if you find one at a good price or something, then that's fine.
    I would go with a Western Digital or Seagate. haven't seen good luck with hitachi or toshiba drives in the past. but I've haven't had good luck with WD either & seagate has fallen considerably due to varying firmware issues across the board.
    any SATA I or II drive will work, but don't get one with the motion sensor built into the drive (all of them have shock protection of some sort) as these will cause problems with your mac & OS X usually as your mac already has a motion / fall sensor.

Maybe you are looking for