help with this code in java please Given a string return the first character in the string
Fantastic news! We've Found the answer you've been seeking!
Question:
help with this code in java please
Transcribed Image Text:
Given a string return the first character in the string if it contains more than 4 characters, and the last character otherwise. firstOrLastChar("kwk") firstOrLastChar("gals") firstOrLastChar("uocrws") For example: Test → 'k' →→→ 's' →'u' System.out.println(first0rLastChar("xdylp")); x Answer: (penalty regime: 0, 10, 20, 50, ... %) Result Reset answer 1 public String 2 // TODO your code goes here 3} firstOrLastChar(String str) { Given a string return the first character in the string if it contains more than 4 characters, and the last character otherwise. firstOrLastChar("kwk") firstOrLastChar("gals") firstOrLastChar("uocrws") For example: Test → 'k' →→→ 's' →'u' System.out.println(first0rLastChar("xdylp")); x Answer: (penalty regime: 0, 10, 20, 50, ... %) Result Reset answer 1 public String 2 // TODO your code goes here 3} firstOrLastChar(String str) {
Expert Answer:
Answer rating: 100% (QA)
Heres the completed Java code for the firstOrLastChar method based on the provided requirem... View the full answer
Related Book For
Statistics The Exploration & Analysis Of Data
ISBN: 9780840058010
7th Edition
Authors: Roxy Peck, Jay L. Devore
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
QUIZ... Let D be a poset and let f : D D be a monotone function. (i) Give the definition of the least pre-fixed point, fix (f), of f. Show that fix (f) is a fixed point of f. [5 marks] (ii) Show that...
-
Let z(k) denote the k-year continuously compounded zero-coupon yield for the current term structure. You are given that z(1) = 0.035, z(2) = 0.041, z(3) = 0.045, z(4) = 0.049, z(5) = 0.051, z(6) =...
-
Is a reduction in interest rates likely to affect spending on pizza? What kinds of spending are sensitive to interest rate fluctuations?
-
Find the coordinates of the points on the curve y = x 3 3x 8 where the gradient is 9.
-
A large company has the opportunity to select one of seven projects-A, B, C, D, E, F, G-or choose the null (donothing) alternative. Each project requires a single initial investment as shown in the...
-
Carlos Arruza Company exchanged equipment used in its manufacturing operations plus $3,000 in cash for similar equipment used in the operations of Tony LoBianco Company. The following information...
-
Explain the relationship and the difference between online analytical processing systems and customer relationship management systems within a business intelligence program.?
-
Explain why our adversarial system of justice is sometimes referred to as civilized warfare. Provide examples. What arguments would you make in favor of retaining this adversarial system? What...
-
a) How is half adder different from full adder? Indicate the difference using truth table and the block diagram. b) Why is Multi-bit adder called Ripple Adder? Show it using a block diagram of two...
-
A sinusoidal wave moving to the left has a wavelength of 5.0 cm and a frequency of 50 Hz. At t=0 s, the wave has a crest at x = 0 cm.
-
Explain the importance of business analytics and international market research for an international business company. What are the risks when this is incomplete and differences among countries are...
-
A regular block of metal has sides 12.2 x 3.7 x 0.95 cm, and a mass of 107g. Find the densi in kg m-3 to a suitable number of significant figures.
-
Explain how upstream and downstream intercompany transactions affect the allocation of profit between the parent (controlling interest) and NCI.
-
On 1 January 20X5, AlbaCore Ltd. reported the following in shareholders equity: Preferred shares, no-par value; authorized, unlimited shares; issued, 75,000 shares $1,875,000 Common shares, no-par...
-
The Pletcher Transportation Company uses a responsibility reporting system to measure the performance of its three investment centers: Planes, Taxis, and Limos. Segment performance is measured using...
-
The article referenced in the previous exercise also reported that 470 of 1000 randomly selected adult Americans thought that the quality of movies being produced was getting worse. a. Is there...
-
Duck hunting in populated areas faces opposition on the basis of safety and environmental issues. In a survey to assess public opinion regarding duck hunting on Morro Bay (located along the central...
-
The article Rinse Out Your Mouth (Associated Press, March 29, 2006) summarized results from a survey of 1001 adults on the use of profanity. When asked How many times do you use swear words in...
-
Lana Priest set up a home sewing business on 1 July 2019. Usually, Lana collects $20 per hour for sewing on the completion of each days work and pays for the maintenance of her machine with cash....
-
Craigs Car Detailing Service had the following accounts and account balances in the adjusted trial balance columns of its worksheet for the year ended 30 June 2019. Required (a) Record the required...
-
The accounts below are taken from the ledger of Bartel Music Consulting on 30 June 2019, the end of the current financial year. Required (a) Record the closing entries that affected the accounts. (b)...
Study smarter with the SolutionInn App