Skip to main content

Problems with Java

1 reply [Last post]
Joined: 2006-02-14

I can't figure out the code for these following questions. For the first questions we are asked to use string methods.

1. Use the following declarations to create a new string variable that contains the phrase "going to Win" and print to the screen.

String word = "Washington";

2. Using the original string value for word create a new string named backwards that contains the reverse of the original string in word and print to the screen.

3. Given the following declarations : String phrase = " WazzUp ? - Who's On FIRST ??? - IDUNNO"; Write the necessary code to count the number of vowels in the string and print appropriate message to the screen.

4. Search the string "George Washington" for the substrings "ton" and "Wish". Print an appropriate message to the screen.

5. Given the following assignment to word

String word = "We the people of the United States in order to form a more perfect union"

Write a method that will find and print the last word in the string.

For my other problem we've been asked to create this shape:

Using nested for loops.

Any help on these questions would be appreciated

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-05-05

Here's what you would do for the nested for loop problem:
[code]for (int i = 0; i < 5; i++) {
for (int j = 0; j < i * 2 + 1; j++) {
Have you even attempted any of these? Show what you've done. I'm not going
to do these for you.