Question

Part 2: Processing Strings (Individual work) Processing user-entered data to follow a specific format is a...

Part 2: Processing Strings (Individual work)

Processing user-entered data to follow a specific format is a common task. Often this involves using string functions to manipulate a set of input strings.

Create a MATLAB script named namephone.m and place these lines of code at the beginning:

name  = input('Enter your first and last name: ','s');

phone = input('Enter your area code and phone number: ','s');

Tasks

Here are useful string functions:  length, strcat, strtrim, lower, upper, strcmp, findstr, strrep

As you work through this, test your code with different badly formed name and phone strings.

  • Assume the user enters his or her name as a single string like this: FirstName LastName. To keep it simple, you may also assume the user is not entering just a single name or more than two names. There will always be at least one space character between the two names.
    • Separate the full namestring into two, separate string variables. Store the first name in a variable named FirstName, and store the last name in a variable named LastName.
    • Remove all leading and trailing spaces from both of the new strings.
    • Example:  name is '  kAthY JonES '            FirstName --> 'kAthY'        LastName --> 'JonES'

Show a sequence of MATLAB commands to do this in the box below.

  • It is possible that the user entered his or her name in a mixture of uppercase and lowercase characters that does not make sense.
    • Modify the FirstName and LastName strings so that only the first letter of each is capitalized.
    • Example:  FirstName --> 'Kathy'   LastName --> 'Jones'

Show your commands below.

  • Suppose the program requires the user’s name be put in last name first and first name last order.
    • Construct a new string named UserNamein this order: LastName, FirstName  (comma is needed)
    • Example: UserName ---> 'Jones, Kathy'

Show the commands need to create UserName.

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Part 2: Processing Strings (Individual work) Processing user-entered data to follow a specific format is a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program to create userids: You work for a small company that keeps the...

    Write a Python program to create userids: You work for a small company that keeps the following information about its clients: • first name • last name • a user code assigned by your company. The information is stored in a file clients.txt with the information for each client on one line (last name first), with commas between the parts. In the clients.txt file is: Jones, Sally,00345 Lin,Nenya,00548 Fule,A,00000 Your job is to create a program assign usernames for a...

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • Problem 1: Write a function ProcessiClicker to take any sized table as an input with at...

    Problem 1: Write a function ProcessiClicker to take any sized table as an input with at least two string column variables LastName and Firstname, and removes any leading and trailing whitespace from variables in LastName and Firstname, and combines the resulting two columns variables into one column named StudentName, with only comma between the last name and the first names. For example, if one record entry in Lastname and Firstname contains " Jones " and " Adam", the final result...

  • 1. Write a program to input a list of names (strings) from the user and store...

    1. Write a program to input a list of names (strings) from the user and store them in an ArrayList. The input can be terminated by entering the empty string or by entering the string “quit”. 2. Add further functionality to your program so that it searches the ArrayList to find the first string and the last string according to dictionary ordering and then prints out these strings (names). Do this exercise without sorting the names in the ArrayList. For...

  • Write a java project that reads a sequence of up to 25 pairs of names and...

    Write a java project that reads a sequence of up to 25 pairs of names and postal (ZIP) codes for individuals (sample input data is attached). Store the data in an object designed to store a first name (string), last name (string), and postal code (integer). Assume each line of input will contain two strings followed by an integer value, each separated by a tab character. Then, after the input has been read in, print the list in an appropriate...

  • Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part...

    Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part 1: In this assignment, you are asked: Stage1:?Design and implement a class named memberType with the following requirements: An object of memberType holds the following information: • Person’s first name (string)?• Person’s last name (string)?• Member identification number (int) • Number of books purchased (int)?• Amount of money spent (double)?The class memberType has member functions that perform operations on objects of memberType. For the...

  • DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to...

    DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to add new phone contacts, display a list of all contacts, search for a specific contact by name, delete a specific contact. The program should provide the user with a console or command line choice menu about possible actions that they can perform. The choices should be the following: 1. Display list of all contacts. 2. Add a new contact. 3. Search for a contact...

  • Make the following modifications/enhancements to Version 0 of the Phonebook application: The phonebook should now contain...

    Make the following modifications/enhancements to Version 0 of the Phonebook application: The phonebook should now contain a first name as well as a last name. The format of the entries in the file should be: last-name first-name phone-number The lookup process now prompts for both a last and a first name A reverse lookup should also be provided, allowing a name to be obtained by supplying the phone number. Rather than continuing until the user signals end-of-file (at the keyboard),...

  • You are asked to define a user-defined data type for students, that will contain the following...

    You are asked to define a user-defined data type for students, that will contain the following information about a student: ID number, first name, last name, major, GPA. Your structure should be cal Student. Based on the defined structure, user name on the command line, show how you will use a loop to search for the given name within the array of 5 students. use an array to record information about 5 students. Then, given a Write a C program...

  • Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user...

    Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT