Answered step by step
Verified Expert Solution
Question
1 Approved Answer
16 Program 1: String Practice.java Write a Java application (a program with a main method) that will do the following steps, IN ORDER. Name the
16 Program 1: String Practice.java Write a Java application (a program with a main method) that will do the following steps, IN ORDER. Name the program String Practice.java. 1) Print a prompt, then input a String from the user and store it in a variable called myString. The String may contain spaces. *** print meaningful messages with every line of output 2) Print the length of myString. Example input: The sky is blue. Correct output: The length of the string is 16. Incorrect output: 3) Create a new variable called upperString and store the uppercase version of myString in it. 4) Create a new variable called lowerString and store the lowercase version of myString in it. 5) Create a new integer variable called XPosition and store the index of the first 'x' in myString in the new variable. 6) Print a prompt, then input a String from the user and store it in a variable called anotherString. The String may contain spaces. 7) Create a new variable called noMs and store the result of changing all of the 'M' characters in anotherString to 'N' 8) Create an integer variable called lastSpace Position and store the index of the last space in anotherString. 9) Create a variable called lastWord. If anotherString contains more than one word, store only the last word in lastWord; otherwise (meaning the string has only one word), store the entire string in lastWord 10) Print meaningful messages with the following output data: upperString lowerString xPosition . . . . noMs lastSpace Position lastWord Compile the program. Debug if necessary until it compiles successfully. Run the program several times. Each time, input a different String. Compare the Actual output to your Expected output. If there are errors, debug the program, compile again, and test again
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started