Outputting each letter in a string twice

hello, im very new to java.
how would i go about writing a program which takes the user's input as a string, then out puts it the string twice.
For example, if the user inputs : twice
it would outout : ttwwiiccee
i know of i would have to use while loop untill the string ends, but i dont know how to to make it so the string outputs twice >_<
thanks =)

import java.util.Scanner;
public class Homework4
public static void main(String[] args)
          Scanner keyboard= new Scanner(System.in);
          String input;
          int i = 0;
          System.out.println("enter a string");
          input = keyboard.nextLine();
          while (i < input.length())
          System.out.print((input.charAt(i))+"" +(input.charAt(i)));
          i++;
ii tthhiinnkk**

Similar Messages

  • To get Length of each word in a String.

    Hi,
    I wanted to know, how to calculate the length of each word in a string.Suppose for example if the input is like this:
    i/p:'Tech on the Net'
    o/p:4 2 3 3
    ie Tech-4 on-2 the-3 Net-3
    another Ex:i am a good boy
    o/p:1 2 1 4 3
    Kindly let me know any PL/SQL function or SQL query which would help to achieve this.
    Thanks&Regards
    Zaheer

    sql>select substr('tech on the net',decode(n,0,1,instr('tech on the net',' ',1,n)+1),
                  decode(instr('tech on the net',' ',1,n+1),0,length('tech on the net')-instr('tech on the net',' ',1,n),
                        instr('tech on the net',' ',1,n+1)- decode(n,0,0,instr('tech on the net',' ',1,n))-1)) wrd,
          length(substr('tech on the net',decode(n,0,1,instr('tech on the net',' ',1,n)+1),
                  decode(instr('tech on the net',' ',1,n+1),0,length('tech on the net')-instr('tech on the net',' ',1,n),
                        instr('tech on the net',' ',1,n+1)- decode(n,0,0,instr('tech on the net',' ',1,n))-1))) cnt
    from(select rownum-1 n
         from dual
         connect by level <= length('tech on the net') - length(replace('tech on the net',' ',''))+1)
    WRD CNT
    tech  4 
    on  2 
    the  3 
    net  3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Formula for getting first letter of the string

    Post Author: jmmj
    CA Forum: Formula
    Hi, I have a problem to get the first letter of the string.  I need to compare first letter first and then change the rest of string to number as unit cost for calculation.  For example, I have string K100, C200,...     if first letter = K then 0 else if first letter = C then tonumber200..... I use CRXI, any assistance will be appreciate.jmmj 

    Post Author: jmmj
    CA Forum: Formula
    It works, thanks Kai!But when I tried to print the report, there are multiple lines shown same invoice number but different unit price. My formular is: IF {OEINPR3.COINTYPE} = 2 OR CCur({OEINPR3.LINETYPE}) = 1  //line type 1 for item,  2 for misc. charge THEN(    IF {OEINPR3.COIN}&#91;1&#93; = "K" OR {OEINPR3.COIN}&#91;1&#93; = "N"  THEN        TONUMBER(MID({OEINPR3.COIN},2,20))    ELSE 0)ELSE      2 //for testing only The result I have: Line#    Inv#    unitprice    total1          IN001    0.00     10.00            IN001   10.00     10.00  2          IN002    0.00     20.00             IN002    20.00     20.00.......The second line of each invoice is correct. How can I print just one line for each invoice which is correct? Thanks!jmmj  

  • Display each words of the string in separate line.

    Dear Javaties,
    pls help me creating this program.
    Display each words of the string in separate line.
    Eg.
    Input value : Testing this string.
    Output : Testing
    this
    string
    Thanks in adavance,
    M. Suresh

    M Suresh,
    We would be delighted to help if only you asked a specific question. Do my work for me is not a specific question.
    The Javaties

  • Text put into a canvas element with context.fillText() always has a black box where each letter goes. If the text is black you just see the black rectangle. If the text is not black you see it on the black bounding box. Surely this is not right.

    This has happened on the last few versions of firefox, as long as canvas has been supported. I see other people's screen shots from canvas tutorials, and the text always looks normal. On my system, any text put into a canvas element via context.fillText() will have a black bounding box for each letter, sized appropriately for the letter. If the text is black, of course you only see rectangles. If the text is a contrasting color, then you can read it, but it looks bizarre.

    Thomas...same kind of crap here.
    I used Custom Text - entered a sentence, hit return, entered another.
    Set to 72 pt.
    The default alignment is centred - I want left aligned text...the text start point stays at the centre of frame and the sentence runs off the edge of the bounding box.
    There is no settings in the Text or Title inspector dialog to correct that!
    Using Transform will not sort it!

  • My ipod doesn't appear with the letters that split up each letter songs, how do i fix it??

    so you know how when you go to music and tap songs. well mine does that but what does not appear on the screen is those letters that divide each letter group of the alphabet. you know it has all the songs starting with the letter a in one place divided by a border letter "A" etc. please help i think its a settings problem not sure, thanks.

    If you're unable to do the Restore, go into Recovery Mode per the instructions here.  You WILL lose all of your data (game scores, etc,) but, for the most part, you can redownload apps and music without be charged again.  Also, if you have IOS-7, read this.

  • New events in iCal are entered on my iMac.  These events pass through correctly to my other computers and iPhone.  However, each new event shows up twice on my iPads.  The clutter is distracting.  Anyone have suggestion as to correcting this annoyance?

    New events in iCal are entered on my iMac.  These events pass through correctly to my other computers and iPhone.  However, each new event shows up twice on my iPads.  The clutter is distracting.  Anyone have suggestion as to correcting this annoyance?

    New events in iCal are entered on my iMac.  These events pass through correctly to my other computers and iPhone.  However, each new event shows up twice on my iPads.  The clutter is distracting.  Anyone have suggestion as to correcting this annoyance?

  • How to get each character in a string

    as in 'C' we use arrays to get each character of a string stored in array.how can we get each character of a string stored in a variable.

    Hi,
    For that you need to do offset.
    for example one variable called VAR contains string 'HUMERAH'.
    if you want each character of that string then you need to decalre as many variable as the number of string.
    like
    data : var1(1),
             var2(1),
    var(3),
    var(4).
    var1 = var+(1).
    var2 = var+1(1).
    var3 = var+2(1).
    var4 = var+3(1).
    now var1,var2,var3,var4. contains the single characters.
    Regards,
    Guru
    mark helpful answers

  • How do I insert a space between each letter? i.e. ABC becomes A B C

    I have a long strand of characters that I would like to insert spaces between and doing it manually is not practical. Can anyone suggest a shortcut or a way to save me a day of sitting and hitting right arrow space bar??

    I need to turn everything into a graph where each Letter, Number and Character is in its own column.
    In this context, set up Tabulators where each and every one is defined as centered. This way, the variable set widths of the sorts (letters, glyphs) will align vertically.
    Note that if you are working with Apple Advanced Typography or Microsoft OpenType font files, your font file may have a special subset of monospaced figure (number) sorts termed Tabular.
    The monospaced figure (number) sorts may either stand on the baseline to align with UPPER CASE or have strokes ascending above and descending below the baseline to align with lower case.
    Your font file may also have other special subsets of figure (number) sorts that are proportionately spaced. You should play with these subsets to see which figures will work well for you.
    In typography (as in photography and lithography) what looks right is rights. Intelligent fonts for composition and intelligent profiles for separation are there to help you with the visuals.
    /hh

  • Remove first letter in a string

    how to remove the first letter in a string ?
    example
    string : hkitty
    result : kitty

    thank you peter... I was just dumb enough to post
    this question... Thank you so much again...Fine with me, you're welcome

  • I want to make a word in all caps without having to use arrow on each letter

    I want to make a word in all caps but not have to use the arrow on each letter.  how can i do it?

    Just be sure that feature is enabled first.
    Settings / General / Keyboard / Enable Caps Lock.
    When capslocked, the arrow turns blue.

  • Why am I getting vertical lines below each letter I type?

    I keep getting vertical lines below each letter that I type when filling in things with Firefox 4. There is one line created for each letter.

    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
    * [[Troubleshooting extensions and themes]]
    In Firefox 4 [http://kb.mozillazine.org/Safe_mode Safe mode] disables extensions and disables hardware acceleration.
    * Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    If disabling hardware acceleration works then check if there is an update available for your graphics display driver.
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)

  • PS CS6: how to create a left to right two-word-curved-headline gradient within the letters without having  to do each letter individually ?

    Q#1:
                I want to learn, how, with Photoshop and Illustrator to create a left to
    right two-word-curved-headline gradient within the letters without having
    to do each letter individually ???
    Q#2:

    https://www.google.com/search?sourceid=chrome-psyapi2&rlz=1C1CHFX_enUS546US546&ion=1&espv= &ie=UTF-8&q=Onlint%20Photoshop…

  • Laserjet CP2025 When printing colored text I get a shadow/halo around each letter

    I am able to print black text perfectly but when I try to print any colored text there is a shadow/halo around each letter that makes it difficult to read. I tried turning off the Edge control in the printing properties section but the problem stayed the same. Any ideas on what my problem might be? Thank you.
    This question was solved.
    View Solution.

    We need more detail. What program are you printing with? Do you get the same color effect no matter what program you are using? The program you use when you get color halos have you used that program before and did not get halos?
    Have you tried a different program an still get halos? If so, have you tried reinstalling you printer software package?
    Do the halos appear to be intentional or do they appear to be a quality print problem? If it looks like a quality ink issue, have you removed the color toners and slowly tilted them side to side to mix the toner? If you do that and get good print results, its time to get new or refurbished color toners (or refill them). 
    If the halos appear to be intentional, you probably have a software problem, anything from a degraded driver to settings in the printer manufacturer's software, to Windows. If the problem seems to be software related, you may want to try my "keep it simple stupid" and not try to find out precisely where the problem is but simple do some broad but quick actions.
    First, I would run your registry repair and registry clean utility(ies). I would do a hard drive defrag & then a registry defrag.
    If none of this ends the problem, I'd uninstall and reinstall the entire software package that came with your printer. Before I did that, I think I'd reinstall the program that is printing halos in color mode. 
    --J
    "I never let schooling interfere with my education" --Mark Twain

  • Help! It's like Pages is haunted! It's erasing each letter one by one automatically and I can't stop it! Virus? It also won't quit?

    Help! Please!
    Is this some sort of weird virus? Did my mouse just go crazy on its own! I click on any document and it speedily reases each letter one by one all on its own, and I can't make it stop. What is going on here! Has anyone ever heard of this? It also won't quit, I hover over the icon on my dock and it just has no response, so I need to force quit...

    As long as it was something as subtle as a book on top of your keyboard.
    Peter

Maybe you are looking for

  • Calling all System Center users! May TechNet Gurus announced!

    The results for May's TechNet Guru competition have been posted! http://blogs.technet.com/b/wikininjas/archive/2014/01/16/technet-guru-awards-december-2013.aspx Congratulations to all our new Gurus for May! We will be interviewing some of the winners

  • CinemaDNG operation in AE and Premiere CS 5.5?

    I worked my way through using CinemaDNG in AE and Premiere. But, there are differences that are me causing confusion: 1) In AE, I use FILE > IMPORT FILE... and select the first DNG file in a folder. The CinemaDNG panel auto-opens. After making adjust

  • Park documents in the furure

    Hello Gurus, I want to create park documents on closed posting periods. As you already know the system issue the error message F5201"Posting period xxx xxxx is not open". Do you know how I can change this system behavior without modifying the posting

  • Preview How To - change keyboard shortcut for dictionary def.

    Hi, I would like to know how to change the keyboard shortcut for checking the dictionary definition of a highlighted word in Preview. Thanks, Brandon

  • Safari Web Content - Constantly using CPU time even when no tabs

    Hello, I have a MacBook Pro Retina (2012), with 16GB of RAM. It is running OSX Mavericks (10.9.4). Recently, I have switched from using it with multiple external monitors, to using it on its own. Here, I have noticed unusually raised usage temperatur