Going national

  • 10
  • Locked
Once diners get over their initial reservations about the proper color of breakfast foods, they fall in love with green eggs and ham. Sam-I-Am has big plans to open a national chain of restaurants featuring his signature dish. He'll launch the Green Eggs and Ham restaurant chain as soon as he can find suppliers of properly colored eggs. We will write a program that replaces the text "green eggs and ham" with "Green Eggs And Ham".
You can't complete this task, because you're not signed in.
  • Popular
  • New
  • Old
You must be signed in to leave a comment
ziv fisher Level 9 , Petah Tikva, israel
Wednesday, 07:58
For this task you need to first Google: 1. Scanner scanner = new Scanner("string"); //take a sentence and divide it to single words. 2. Character.toUpperCase(i); // take a letter at index(i) and turn it into upperCaseLetter. 3. "string".subString(i); 4. StringBuilder - it helps to learn about it as well but not mandatory.
Pavel Naumovich Level 12 , Chippenham, United Kingdom
30 September, 17:15
.split(" ") Character.toUpperCase charAt are your friends
Ibrahim Level 8 , Minneapolis, United States
12 September, 22:07
I spent over 20 hours to finish this task. When I saw this task, I knew I wouldn't be able to complete it with my current knowledge in Java. I knew there were methods of the String class and the Character class that are involved in the solution, so I had to go to my java textbook and study the appropriate sections. Hence, I spent over 20 hours studying for this task and solving it.
Timboo Level 16 , Shantou, China
4 July, 11:31
Can any one help me? what's the problem of my code?
Lucas Hoage Level 14 , Savannah, United States
4 June, 19:24
This one was a little tough. Still solvable. You can use StringBuffer to make the string mutable. In order to replace the value, you have to pass the char back as a String. String has a method to do this. Remember that index of 0 can be a space. So be sure to include 0 in your condition statement.
Cam Level 22 , Auckland, New Zealand
1 April, 05:12
A little hint. Pass the string into a character array. If a char c in the charArray == ' ', the next letter needs to be capitalized. It does not matter if that next char is also a ' ' , it will still pass the task ;)
Artur Verdyan Level 24 , Hoboken, United States
19 March, 18:30
I see the "input data" with which I need to work, I solve it with that data in mind, but it fails, just because there are also some input data which is not visible to me...Why?
Bill Hine Level 9 , Sarasota, United States
4 December 2019, 19:22
. Another one of code gyms hidden requirements you only find out about after you hit verify make sure you account for the fact that the test input does not mean that each word will be single spaced they can be double spaced or more.
oli blaustrom Level 18 , Luzern, Switzerland
26 February, 18:19
How'd you solve this? I could only think of a for loop or changing to scanner; but there has to be a smarter method
Vesa Level 41 , Kaliningrad, Russia
22 November 2019, 10:25
Fine! The task forces us to study the methods of the String and Character classes.
Steve Level 9 , Denver, United States
6 August 2019, 18:08
I hope this isnt breaking the rules but this is key to pass the last task String[] words = s.trim().split("\\s+");