Write a program named StringCompare.java which will prompt the user for three Strings, his/her favorite color, favorite fruit and favorite flower. Use Scanner object to read in user's strings in corresponding order (color, fruit, flower). (I will expect you to use three next() methods for three inputs!) Conduct two separate checks in the following order: 1. If either of the values entered for color or fruit is 'orange', convert both color and fruit to UPPERCASE. 2. If either of the values entered (for color or flower) is 'violet', convert both values for color and flower to "vIoLeT" (alternating lower and upper case letters). Then print each value on its own line: color, then fruit, then flower.
Write a program named StringCompare.java which will prompt the user for three Strings, his/her favorite color, favorite fruit and favorite flower.
Use Scanner object to read in user's strings in corresponding order (color, fruit, flower). (I will expect you to use three next() methods for three inputs!)
Conduct two separate checks in the following order:
1. If either of the values entered for color or fruit is 'orange', convert both color and fruit to UPPERCASE.
2. If either of the values entered (for color or flower) is 'violet', convert both values for color and flower to "vIoLeT" (alternating lower and upper case letters).
Then print each value on its own line: color, then fruit, then flower.
Given:
Write a program named StringCompare.java which will prompt the user for three Strings, his/her favorite color, favorite fruit and favorite flower.
Use Scanner object to read in user's strings in corresponding order (color, fruit, flower). (I will expect you to use three next() methods for three inputs!)
Conduct two separate checks in the following order:
1. If either of the values entered for color or fruit is 'orange', convert both color and fruit to UPPERCASE.
2. If either of the values entered (for color or flower) is 'violet', convert both values for color and flower to "vIoLeT" (alternating lower and upper case letters).
Then print each value on its own line: color, then fruit, then flower.
Step by step
Solved in 3 steps with 3 images