Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: Help needed

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    5
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Help needed

    SHOUTS AND whispers.
    Write a program that reads in a line of text and then outputs that line of text first in all uppercase letters and then in all lowercase letters.

    INPUT and PROMPTS. The program prompts for a line of text as follows: "Enter the text: " and then reads in an entire line of text as a String .

    OUTPUT . There are four lines of output . The first line is "The text in all upper case is: ". The second line is the line that was read in, displayed in all uppercase. The third line is "The text in all lower case is: " and the fourth line is the original line that was read in, displayed in all lowercase.

    CLASS NAMES. Your program class should be called ShoutAndWhisper.

    This is what I have so far:

    import java.util.Scanner;

    public class ShoutAndWhisper
    {
    public static void main(String[] args)
    {
    Scanner scannerObject = new Scanner (System.in);

    System.out.println("Enter the text: ");
    scannerObject.next();

    System.out.println("The text in all upper case is: ");


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: Help needed

    Scanner's reading method has a return type of String Scanner (Java Platform SE 7 )
    and String is capable of converting a text into uppercase or lower case String (Java Platform SE 7 )

  3. #3
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Help needed

    If you are inputting text via a string literal, shouldn't your input be:

    scannerObject.nextLine()
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help needed

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly.

  5. #5
    Junior Member
    Join Date
    May 2014
    Posts
    5
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Help!!!

    HATE and LOVE.
    Write a program that reads in a line of text and then outputs that line of text with the first occurrence of "hate" changed to "love". For example, a possible sample dialog might be the following:

    Enter a line of text.
    I hate you.
    I have rephrased that line to read:
    I love you.


    You can assume that the word "hate" occurs in the input. If the word "hate" occurs more than once in the line, your program should replace only the first occurrence of "hate".

    INPUT and PROMPTS. The program prompts for a line of text as follows: "Enter a line of text: " and then reads in an entire line of text as a String .

    OUTPUT . The output is "I have rephrased that line to read:" followed by a new line consisting of the original line transformed as described above.

    CLASS NAMES. Your program class should be called HateToLove

  6. #6
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: What is wrong with my Code


  7. #7
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: What is wrong with my Code


  8. #8
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: Help!!!

    Please read String (Java Platform SE 7 )
    String object in java is capable of replacing the first occurrence of the specified word.

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help needed

    Threads merged. Please only one thread per topic.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  10. The Following User Says Thank You to Norm For This Useful Post:

    Tripleg (June 19th, 2014)

  11. #10
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help needed

    Please:

    1. DON'T post duplicate topics (you're nearly a spammer and further duplicate posts will require further admin action.)

    2. DO post your code correctly.

  12. #11
    Junior Member
    Join Date
    May 2014
    Posts
    5
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Help needed

    Sorry, I am new to this and I am trying to figure out how to do this correctly. I apologize

  13. #12
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help needed

    What haven't you figured out yet? If you still have questions about posting topics or code, then ask (you can PM me) or read the Announcement topic at the top of the sub-forum. If you still have questions about your program, then provide what you've done with the advice already given, the results you've experienced, post your updated code, and ask any new questions you have. Posting the same thing over and over again will not get you the help you need.

    Editing your posts that have been responded to is another DON'T, because it modifies or eliminates the context of the response, typically making it pointless and a waste of time. Stick by your posts and move on, hopefully forward, even when you've made mistakes. We all make mistakes, and we do our best to learn from them and move on.

    Good luck!

  14. The Following User Says Thank You to GregBrannon For This Useful Post:

    Tripleg (June 19th, 2014)

  15. #13
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help needed

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/88631-whats-wrong-code.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


  16. The Following User Says Thank You to copeg For This Useful Post:

    Tripleg (June 19th, 2014)

Similar Threads

  1. Grails Developer Needed - URGENTLY NEEDED *WORK FROM HOME*
    By IngeniumR in forum Paid Java Projects
    Replies: 0
    Last Post: February 5th, 2013, 07:19 AM
  2. help needed!!
    By arvindbis in forum Web Frameworks
    Replies: 0
    Last Post: October 9th, 2011, 10:43 AM
  3. HELP NEEDED
    By nicola177 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 4th, 2011, 11:17 AM
  4. help needed
    By The Lost Plot in forum Loops & Control Statements
    Replies: 4
    Last Post: March 16th, 2010, 03:55 AM
  5. [SOLVED] A little help needed..
    By JavaStudent87 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 22nd, 2010, 06:54 PM