Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Word capitalization comes up frequently. For this assignment, compose a method called capitalize, which takes 2 String parameters and returns a String. The first parameter

 

Word capitalization comes up frequently. For this assignment, compose a method calledcapitalize, which takes 2 String parameters and returns a String.

The first parameter is the String to process (expected to be a single'word'). The second parameter indicates the capitalization mode to apply:


LOW: the output String should be in all lower cases

HI: the output String should be in all upper cases

CAP: the output String should have its first letter capitalized and the remaining letters in lower case


The second parameter can be entered with any casing but any other value beside LOW, HI, or CAP will make the method return its first parameter unchanged.



Sample Runs: System.out.println(capitalize("croCoDILe", "low"));

System.out.println(capitalize("croCoDILe", "Hi"));

System.out.println(capitalize("croCoDILe", "CAP"));

System.out.println(capitalize("croCoDILe", "mid"));


Output

crocodile

CROCODILE

Crocodile

croCoDILe

Step by Step Solution

3.45 Rating (148 Votes )

There are 3 Steps involved in it

Step: 1

Heres a Java method capitalize that implements the described functionality This capitalize method ta... 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

Java Software Solutions

Authors: John Lewis, William Loftus

9th Edition

9353063612, 978-9353063610

More Books

Students also viewed these Programming questions

Question

How can a method reference be used to define an event handler?

Answered: 1 week ago