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
Which of the following kinds of software is a sophisticated type of application software that assists a professional user in cre
Setler [38]

Answer:

The answer is A. CAD which means Computer-Aided Design.

Explanation:

CAD is used for creating different designs, simulations and scientific diagrams, some examples of CAD software include AutoCAD and Solidworks.

For reference the other acronyms mean:

Desktop publishing (DTP)

Computer-based training (CBT)

Web-based training (WBT)

4 0
3 years ago
Your computer is crashing on a regular basis. Which of the following is an operation available to the user that should help rese
Gwar [14]
System restore application. Hopefully it helps.
6 0
4 years ago
Read 2 more answers
If you set up a network in your home to share your internet connection with several laptops, what type of network have you creat
Alex_Xolod [135]

Answer:

P2P

Explanation:

Originally stood for "Peer to Peer." The "colleagues" are computers in a P2P network that are linked via the Web to each other. By having a central server, files can be exchanged directly among devices on the network. In other words, any machine on a Distributed system becomes both a file server and a client.

3 0
3 years ago
What performance specification does 2 GHz refer to?
Korvikt [17]

Answer:

GHz is the speed of the processor

Explanation:

6 0
3 years ago
Gustavo is completing his homework online. When he uses a computer, what converts the information he inputs into instructions th
Otrada [13]
I can not understand your question, about it. What is homework of Gustavo working in, Visual or Dev C++ with any language?
4 0
3 years ago
Read 2 more answers
Other questions:
  • John, the network administrator of XYZ Corporation, is interested in changing the format of text from the American Standard Code
    10·1 answer
  • Which charges a fee for access to read, research, or copy articles and other published materials?
    11·1 answer
  • Which remote assistance option requires peer name resolution protocol (pnr) and ipv6?
    5·1 answer
  • Assume that a large number of consecutive IP addresses are available starting at 198.16.0.0 and suppose that two organizations,
    13·1 answer
  • The idea that managers tend to communicate more with other managers who share similar beliefs and experiences is represented by
    8·1 answer
  • Which entity has the principal responsibility to control the execution of processes?
    14·1 answer
  • What piece of marketing material would be the most important when running an e-commerce website? coupons location logarithms cre
    5·2 answers
  • What is the best way to show a complex data chart in word?
    6·1 answer
  • PLEASE HELP ILL MARK BRAINLIEST!!!
    10·1 answer
  • ¿Qué diferencia existe entre un virus biológico y virus informático?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!