1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gregori [183]
3 years ago
12

This exercise asks you to write a program that tests some of the built-in subroutines for working with Strings. The program shou

ld ask the user to enter their first name and their last name, separated by a space. Read the user's response using TextIO.getln(). Break the input string up into two strings, one containing the first name and one containing the last name. You can do that by using the indexOf() subroutine to find the position of the space, and then using substring() to extract each of the two names. Also output the number of characters in each name, and output the user's initials. (The initials are the first letter of the first name together with the first letter of the last name.) A sample run of the program should look something like this:
Please enter your first name and last name, separated by a space.
? Mary Smith
Your first name is Mary, which has 4 characters
Your last name is Smith, which has 5 characters
Your initials are MS
Computers and Technology
1 answer:
klasskru [66]3 years ago
5 0

Answer:

Java.

Explanation:

// Get user input

System.out.print("Please enter your first name and last name separated by a space: ");

userInput = TextIO.getln();

// Find index of space character

int spaceIndex = userInput.indexOf(' ');

// Extract first and last name using space character index

// I have used length() method to get length of string userInput.

String firstName = userInput.substring(0, spaceIndex-1);

String lastName = userInput.substring(spaceIndex+1, userInput.length()-1);

// Print the required statements

System.out.print("Your first Name is %s, which has %d characters%n", firstName, firstName.length());

System.out.print("Your last Name is %s, which has %d characters%n", lastName, lastName.length());

// I have used space character Index to get the Initial of last name

System.out.print("Your initials are %s%s", firstName.substring(0,0), lastName.substring(spaceIndex+1, spaceIndex+1));

You might be interested in
What is self management.​
OLEGan [10]

Answer:

Self management is being able to control your emotion & behavior. This is a very important life skill

Explanation:

8 0
3 years ago
Read 2 more answers
Which ofthe following calls on human feelings, basing the argument onaudience needs or sympathies?
Artyom0805 [142]

Answer: a) Emotional appeal

Explanation: Calls on feeling of human is referred as the emotion of the humans ,thus it is said to be an emotional appeal. Other appeals in the options are for the call on technical,logical or unexpected error reason and does not relate to the human audience needs or sympathies .But emotional appeal deals with these need on being called.  So, option (a) is the correct option .

5 0
3 years ago
In 1928 what film was the first all talking feature
goblinko [34]

Lights of New York was the 1928 what film was the first all talking feature.

8 0
3 years ago
In best practice, should you use all lowercase, all uppercase or a mixture of cases in HTML tag names?
mixas84 [53]
B considering it’s proper english, we went through this about a week ago
7 0
2 years ago
How and why Steve Jobs left Apple Computer.
Artist 52 [7]

Answer:

Jobs was forced out of Apple in 1985 after a long power struggle with the company's board and its then-CEO John Sculley. ... He was largely responsible for helping revive Apple, which had been on the verge of bankruptcy.

Explanation:

6 0
3 years ago
Other questions:
  • What are the characteristics of the Global Address List? Check all that apply.
    13·1 answer
  • A computerized spreadsheet program is useful for
    6·2 answers
  • [c++] Write a recursive function takes a word string as input argument and reverse the word. Print out the results of recursive
    14·1 answer
  • A store owner keeps a record of daily transactions in a text file. Each line contains three items: The invoice number, the cash
    7·1 answer
  • Write the name of the tab, the command group, and the icon that you need to use to justify
    14·1 answer
  • This standard library function returns a random floating-point number in the range of 0.0 up to 1.0 (but not including 1.0).
    10·1 answer
  • 13) An-Excel-file-is-generally called-a-l-an:
    6·1 answer
  • 14 Copy a picture of a crane on the next page. Do not trace them. Make a freehand sketch. (2) 2 Look at the placed where the Mar
    11·1 answer
  • A Network Intrusion Detection System watches for potentially malicious traffic and _______ when it detects an attack.
    15·1 answer
  • The rules that govern the correct order and usage of the elements of a language are called the of the language:.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!