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.
1
Expert's answer
2016-03-25T10:23:04-0400
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() ); } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment