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
Create a list words = ['is', 'NLP', 'fun', '?']. Use a series of assignment statements (e.g. words[1] = words[2]) and a temporar
Svetlanka [38]

Answer:

words = ['is', 'NLP', 'fun', '?']

tmp = words[1]

words[1] = words[0]

words[0] = tmp

words[3] = '!'

print(words)

Explanation:

- Create the list

- Assign the new values using <em>tmp</em> variable

- Print the result

Since tuples in Python are unchangeable, you cannot transform the list using tuple assignment.

5 0
3 years ago
What can help prevent issues related to downloading content from the internet?
vodka [1.7K]

Answer:

D)

Explanation:

3 0
3 years ago
Anu wishes to prepare a program to display the value of numbers from 1 to 25. The program that Anu prepared is given below. Ther
sergiy2304 [10]

Answer:

Programming is a set of instructions i.e. Input given by the user to the computer to perform a particular task and give the desired result i.e. output.

Final Answer

‌s=0

for i in range(1,26):

s=s+ i

print(s)

Explanation:

IF THE ANSWER IS CORRECT THEN MARK A BRAINLEST

5 0
3 years ago
Read 2 more answers
Which of these is NOT a benefit of being connected 24/7?
Serjik [45]

Answer:

c

Explanation:

answering messages is a more of a choice than a benifit.

3 0
3 years ago
Anybody remember that football game that everyone used to play during school
fiasKO [112]

Answer:

Like an actual video game or the one where you would play during recess then get in trouble when someone got hurt

Explanation:

6 0
3 years ago
Other questions:
  • Given the following business scenario, create a Crow's Foot ERD using a specialization hierarchy if appropriate. Granite Sales C
    12·1 answer
  • The tax calculator program of the case study outputs a floating-point number that might show more than two digits of precision.
    7·1 answer
  • what are Include the data on usage you gather from your interactions with friends or by listening to people on the radio or on T
    7·1 answer
  • Being nice take the points​
    9·1 answer
  • I get such an error when I turn on the computer, how can I fix it?
    7·1 answer
  • Which of these options highlights the need for learning algorithms
    9·2 answers
  • 8.3 code practice edhesive PLEASE HELP AND HURRY
    9·1 answer
  • Explain how a stored procedure is processed by the DBMS query processor (including the type of return value after the query is p
    15·1 answer
  • HELPPPPP 20 POINTS CORRECT ANSWER GETS BRAINLIEST<br>sorry wrong amount of points ;-;
    13·2 answers
  • How can you make your MakeCode micro:bit program display either the letter<br> A or the letter B?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!