Results 1 to 6 of 6
- 07-16-2011, 12:50 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 40
- Rep Power
- 0
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.
- 07-16-2011, 01:06 AM #2
You should be able to start with a small program that can read a sentence."Write a program that takes a one-line sentence as input and then outputs the following response:
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.
- 07-16-2011, 05:01 AM #3
Member
- Join Date
- Jun 2011
- Posts
- 40
- Rep Power
- 0
Thanks, I'll try to do smth...
- 07-16-2011, 07:26 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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.
-
Spoonfed answer deleted, and fakepics500 warned to avoid doing this again.
- 07-16-2011, 07:43 AM #6
Member
- Join Date
- Jul 2011
- Posts
- 43
- Rep Power
- 0
Similar Threads
-
Beginners fault
By NGE in forum New To JavaReplies: 6Last Post: 06-23-2011, 07:28 PM -
Looking for an Ebook for beginners
By danko in forum New To JavaReplies: 3Last Post: 04-11-2011, 01:29 AM -
Need help with a programming exercise
By ararar in forum New To JavaReplies: 9Last Post: 11-19-2010, 05:57 AM -
Help with beginners program
By DanK in forum New To JavaReplies: 6Last Post: 12-15-2008, 05:02 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks