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]
2 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]2 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
Write a program that prompts the user for a word or phrase, and determines if the entry is a palindrome. A palindrome is a word
vekshin1

Answer:

Explanation:

The following code is written in Python. It asks the user for an input. Then cleans the input using regex to remove all commas, whitespace, and apostrophes as well as making it all lowercase. Then it reverses the phrase and saves it to a variable called reverse. Finally, it compares the two versions of the phrase, if they are equal it prints out that it is a palindrome, otherwise it prints that it is not a palindrome. The test case output can be seen in the attached picture below.

import re

phrase = input("Enter word or phrase: ")

phrase = re.sub("[,'\s]", '', phrase).lower()

reverse = phrase[::-1]

if phrase == reverse:

   print("This word/phrase is a palindrome")

else:

   print("This word/phrase is NOT a palindrome")

7 0
2 years ago
Computer C’s performance is 4 times as fast as the performance of computer B, which runs a given application in 28 seconds. How
slamgirl [31]

Answer:

112

Explanation:

Since computer C's performance is 4 times faster, naturally I'd multiply 28 by 4.

6 0
3 years ago
A _____ stores definitions, such as data types for fields, default values, and validation rules for data in each field.
PIT_PIT [208]
The answer to this question is the term Data Dictionary. A Data Dictionary or also known as metadata repository is a set of information that is stored which contains data, meanings, and values. The data dictionary can be used as a tool for communication between the stakeholders.
5 0
3 years ago
Hi guy how do i make money in app cuz im desperate for 1 right now​
Margarita [4]

Answer:

we need context

Explanation:

7 0
3 years ago
Read 2 more answers
Router 1 is configured with static NAT. Addressing on the router and the web server are correctly configured, but there is no co
marin [14]

Answer:

The router NAT configuration has an incorrect inside local address.

Explanation:

The term Inside in a <em>Network Address Translation (NAT) </em>context refers to networks owned by an organisation that must be translated. When NAT is configured, hosts within this network have addresses in one space (known as the local address space). These hosts appear to those users outside the network as being in another space (known as the global address space).

The term Outside refers to those networks to which the stub network connects, and which are not under the control of an organisation. Also, hosts in outside networks can be subject to translation, and can thus have local and global addresses

7 0
2 years ago
Other questions:
  • Elvis has asked Bonnie out on a date to a baseball game. Elvis is a friend of Bonnie's classmate Ginger and she has met him a fe
    5·2 answers
  • What is the most recognized and widely used database of published nursing practice literature?
    15·1 answer
  • 1. What is Java SE?
    11·2 answers
  • A network administrator is reviewing a network design that uses a fixed configuration enterprise router that supports both LAN a
    8·1 answer
  • To show the navigation pane if it is hidden, click the ____ button
    12·2 answers
  • What are some characteristics of pseudocode? Check all that apply. Pseudocode is an informal way of expressing ideas and algorit
    11·2 answers
  • What do you mean by real time system? Why real time system needs to response within limited time?
    6·1 answer
  • View which is used to specify the tables fields , their data types and properties ​
    9·2 answers
  • If, after fetching a value from memory, we discover that the system has returned only half of the bits that we expected; it is l
    8·1 answer
  • if you want to clear a single file, what move instruction would you use? group of answer choices none of the choices file to wor
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!