Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Norm

Thread: Programming exercise for beginners

  1. #1
    FOX427 is offline Member
    Join Date
    Jun 2011
    Posts
    54
    Rep Power
    0

    Default Programming exercise for beginners

    Hi guys! want to implement but don't know where to start. here is the task:

    "Write a program that takes a one-line sentence as input and then outputs the following response: If the sentence ends with the question mark ‘?’ and the input contains an even number of characters, then output the word “Yes”. If the sentence ends with the question mark ‘?’ and the input contains an odd number of characters, then output the word “No”.If the sentence ends with an exclamation mark ‘!’, then output the word “Wow”. In all other cases, your program will output the string “You always say” followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there no quotes in the output. Your program should have a loop that allows the user to repeat this until the user indicates that she/he wants to end the program. Your program does not have to check the input to see that the user entered a legitimate sentence."

    This might be easy for you guys, I am just beginner, you don't have to write whole code, you can just guide me. thanks.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    "Write a program that takes a one-line sentence as input and then outputs the following response:
    You should be able to start with a small program that can read a sentence.
    Look at the Scanner class. There are lots of code samples on the forum. Use Search.
    For examining the sentence look at the String class. It has lots of methods for searching and testing values.

    When you get that working then come back with your questions about the rest of your assignment.
    sunde887 likes this.

  3. #3
    FOX427 is offline Member
    Join Date
    Jun 2011
    Posts
    54
    Rep Power
    0

    Default

    Thanks, I'll try to do smth...

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Please don't spoonfeed, you've been told this before. Let them show the work and tell them what's wrong rather than give them an answer. Try not to post actual code, at best do descriptions in pseudo code or plain English.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  6. #6
    fakepics500 is offline Member
    Join Date
    Jul 2011
    Posts
    43
    Rep Power
    0

Similar Threads

  1. Beginners fault
    By NGE in forum New To Java
    Replies: 6
    Last Post: 06-23-2011, 07:28 PM
  2. Looking for an Ebook for beginners
    By danko in forum New To Java
    Replies: 3
    Last Post: 04-11-2011, 01:29 AM
  3. Need help with a programming exercise
    By ararar in forum New To Java
    Replies: 9
    Last Post: 11-19-2010, 05:57 AM
  4. Help with beginners program
    By DanK in forum New To Java
    Replies: 6
    Last Post: 12-15-2008, 05:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •