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
Illusion [34]
3 years ago
13

Write a method named lastFirst that accepts a string as its parameter representing a person's first and last name. The method sh

ould return the person's last name followed by the first initial and a period. For example, the call lastFirst("Marla Singer") should return "Singer, M." . You may assume that the string passed consists of exactly two words separated by a single space.
Computers and Technology
1 answer:
Usimov [2.4K]3 years ago
7 0

I'm going to assume this is Java, because you said "method" meaning it will be some sort of object oriented language, and Java's really common. Here would be the full program, but you can just take the method out isolated if you need it.

package lastname;

public class LastName {

   public static void main(String[] args) {

       // Example usage:

       String name = LastName.lastName("Garrett Acord");

       System.out.println(name);

       // Output: Acord G.

   }

   public static String lastName(String fullName)

   {

       String[] splitName = fullName.split(" ");

       return String.format("%s %s.", splitName[1], splitName[0].substring(0,1) );

       

   }

   

}

You might be interested in
Write a program that reads in your question #2 Python source code file and counts the occurrence of each keyword in the file. Yo
scoray [572]

Answer:

Here is the Python program:

import keyword  #module that contains list of keywords of python

filename = input("Enter Python source code filename: ") # prompts user to enter the filename of a source code

code = open(filename, "r") # opens the file in read mode

keywords = keyword.kwlist #extract list of all keywords of Python and stored it into keywords

dictionary = dict() #creates a dictionary to store each keyword and its number of occurrence in source code

for statement in code: # iterates through each line of the source code in the file

   statement = statement.strip() # removes the spaces in the statement of source code  

   words = statement.split(" ") #break each statement of the source code into a list of words by empty space separator

   for word in words:# iterates through each word/item of the words list  

       if word in keywords:#checks if word in the code is present in the keywords list of Python  

           if word in dictionary: #checks if word is already present in the dictionary

               dictionary[word] = dictionary[word] + 1 #if word is present in dictionary add one to the count of the existing word

           else: #if word is not already present in the dictionary  

               dictionary[word] = 1 #add the word to the dictionary and set the count of word to 1

for key in list(dictionary.keys()): #iterates through each word in the list of all keys in dictionary  

   print(key, ":", dictionary[key])# prints keyword: occurrences in key:value format of dict

Explanation:

The program is well explained in the comments attached with each line of the program.  

The program prompts the user to enter the name of the file that contains the Python source code. Then the file is opened in read mode using open() method.

Then the keyword.kwlist statement contains the list of all keywords of Python. These are stored in keywords.

Then a dictionary is created which is used to store the words from the source code that are the keywords along with their number of occurrences in the file.

Then source code is split into the lines (statements) and the first for loop iterates through each line and removes the spaces in the statement of source code .

Then the lines are split into a list of words using split() method. The second for loop is used to iterate through each word in the list of words of the source code. Now each word is matched with the list of keywords of Python that is stored in keywords. If a word in the source code of the file is present in the keywords then that word is added to the dictionary and the count of that word is set to 1. If the word is already present in the dictionary. For example if there are 3 "import" keywords in the source code and if 1 of the import keywords is already in the dictionary. So when the second import keyword is found, then the count of that keyword is increased by 1 so that becomes 2.

Then the last loop is used to print each word of the Python that is a keyword along with its number of occurrences in the file.

The program and its output is attached in a screenshot. I have used this program as source code file.

7 0
3 years ago
List three reasons you might use hwinfo when troubleshooting and upgrading a computer
Elza [17]

Solution:

three reasons you might use hwinfo when troubleshooting and upgrading a computer are as follows:

1) If we want to identify a hardware component with out opening the case.

2. if we want identify Features of a motherboard, video card, or processor.

3. establish benchmarks for the components in

8 0
4 years ago
You are out on the water. you do not understand what another boater intends to do. what sound signal should you make?
olchik [2.2K]
When you do not understand what another boater intends to do, you are required to communicate this to the boater by sounding five or more short and rapid blasts. A short blast means a blast that takes about one second. The two vessel must stop or slow down until they clearly understand each other intent.
7 0
3 years ago
Alex leads a team of eight members. Arrange his tasks in sequential order of phases of group dynamics. What are the stages in gr
Alborosie

Answer and Explanation

There are five stages of group development which Alex should follow.

i) Stage 1: Forming-this is where he forms a team which will follow the other stages.

ii)Stage 2: Storming - In this stage is where the members set their goals and boundaries.

iii)Stage 3: Norming- This is where the team comes together in terms of ideas. In this stage members are ready to move forward with big expectations.

iv)Stage 4: Performing.-This is where  now the team is now accomplishing or implements their ideas and they are now getting the benefits.In this stage members argue positively.

v)Stage 5: Adjourning-This is the stage where the group has accomplished their mission.And now the group is dissolved

7 0
3 years ago
Please help me with this!
Aleksandr [31]

def zipZapZop():

   number = int(input("Enter the number: "))

   dictionary = {3: "zip", 5: "zap", 7: "zop"}

   amount = 0<em> #amount of non-divisible numbers by 3, 5 and 7</em>

<em>    for key, value in dictionary.items():</em>

       if(number%key == 0): <em>#key is the number</em>

           print(value) <em>#value can be or zip, or zap, or zop</em>

       else: amount += 1 #the number of "amount" increases every time, when the number is not divisible by 3, or 5, or 7

   if(amount == 3): print(number)    <em>#if the number is not by any of them, then we should print the number</em>

zipZapZop()

4 0
3 years ago
Other questions:
  • Question 4 of 10
    5·1 answer
  • I need help to find out what is wrong with this program and my variable, "exponent" comes out as 0 in the output instead of the
    14·1 answer
  • ____________________ software is a type of security software designed to identify and neutralize web bugs, ad-serving cookies, a
    8·1 answer
  • A systems analyst draws a lifeline with an X at the end. This lifeline represents _____.a. a message that cannot be deliveredb.
    9·2 answers
  • Help! Computer Science Discoveries. Hurry its timed
    15·1 answer
  • Irene is creating a wireframe of a website she is working on to show her client. In which phase of the development process is sh
    13·1 answer
  • What charts the cost to the company of the unavailability of information and technology and the cost to the company of recoverin
    15·1 answer
  • What is responsible for recording an image of an object with camera <br> Pls I neeed it right know
    8·1 answer
  • What happen if there is no authentication??
    10·2 answers
  • To have the full protection of the law, copyrights, patients, and ______ should be registered with the government.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!