60 635
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #58691 in Java | JSP | JSF for mike

Question #58691
Prompt the user to enter a three word phrase as one string and then:

Display the number of characters (including spaces) in the phrase.
Display the number of characters in the middle word.
Display the final word in all upper case.
Expert's answer
import java.util.Scanner;

public class Main
{
public static void main (String[] args)
{

Scanner sc = new Scanner(System.in);

System.out.println("Please enter a three word phrase as one string");
String str = sc.nextLine();

System.out.println("The number of characters (including spaces) in the phrase - "+str.length());

String[] arr=str.split(" ");
System.out.println("The number of characters in the middle word - "+arr[1].length());

System.out.println("The final word in all upper case - "+arr[2].toUpperCase() );
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions