Question: In this lab, you complete a partially written Java program that includes built - in functions that convert strings to all uppercase or all lowercase.

In this lab, you complete a partially written Java program that includes built-in functions that convert strings to all uppercase or all lowercase. The program prompts the user to enter any string. To end the program, the user can enter done. For each string entered, call the built-in functions lower() and upper(). The program should call these functions using a string object, followed by a dot (.), followed by the name of the function. Both of these functions return a string with the string changed to uppercase or lowercase. Here is an example:
sample = "This is a String." result = sample.lower() result = sample.upper()
The source code file provided for this lab includes the necessary variable initializations and the necessary input and output statements. Comments are included in the file to help you write the remainder of the program.
An example of the program is shown below:
Enter 9 lowercase characters: adventure ADVENTURE Enter 9 uppercase characters: ADVENTURE adventure
import javax.swing.*;
public class ChangeCase
{
public static void main(String args[])
{
String sample;
String result;
sample = JOptionPane.showInputDialog("Enter a string or done when you want to quit.");
while(sample.compareTo("done")!=0)
{
// Call toLowerCase() method here and print the result.
System.out.println("Lowercase: "+ result);
// Call toUpperCase() method here and print the result.
System.out.println("Uppercase: "+ result);
sample = JOptionPane.showInputDialog("Enter a string or done when you want to quit.");
}
System.exit(0);
}// End of main() method.
}// En

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!