Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please show me how to fix my code, I can't figure out why it won't work. SameStarChar.java public class SameStarChar { /** Write the method

Please show me how to fix my code, I can't figure out why it won't work.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

SameStarChar.java public class SameStarChar { /** Write the method named sameStarChar(). Given a String str, return true if for every ** (star) in the string, if there are chars both immediately before and after the star, they are the same. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Note: This is a little tricker than it looks. One way to look at the problem is to see in what circumstances you should return false. You only return false if the characters on either side of the * are different. That means that if there are no characters in front of, or behind the *, then you should return true, not false. Examples: sameStarChar("xy*yzz") returns true sameStarChar("xy*zzz") returns false sameStarChar("*xa*az") returns true @param str the input String to process. @return true if the characters before and after are the same. 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45} // TODO Write the sameStarChar method here. public boolean sameStarChar (String str) { int i = 0; boolean answer = true; while (i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

1. What are the goods and services going to be produced?

Answered: 1 week ago

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago