Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be written for MatLab: 3. In this question, you will write a program that manipulates a text variable entered by the user (a) Write

Must be written for MatLab:

image text in transcribed

3. In this question, you will write a program that manipulates a text variable entered by the user (a) Write a program that requests a text string from the user (b) Complete your program so that it counts the number of words contained in the text string and displays the result HINT1: Notice that counting the number of words comes back to counting the number of blank spaces. You wl nced to find the relation between the number of words and the number of spaces. HINT 2: You can use the function length) to determine the number of characters in the input string. Then you can use a while or for loop to determine the number of blank space in the string (c) Check if the word "pizza" exists in the text string. You can display the string "The word pizza is in the string." or "The word pizza is not in the string." HINT 3: strfind) You should also upload the final MatLab program to http://d21.arizona.edu. 4. (a) Write a MatLab program that uses Matlab's switch construction to convert a date entered by the user in the form mm/dd/yyyy into its text form (i.e., Month day, ycar). For example, if 02/17/2019 is entered, the program should print out "February 17, 2019". To read in a text string entered by the user, use the following form of the input statement Date input ('Enter date as mm/dd/yyyy: ','s') The string variable Date will then be a 10-element vector, whose elements are the individual characters in the string. You can extract a piece of the string and convert it to a numeric variable using the colon opcrator to specify a range of elements as a vector index and the MatLab function str2num O. For example, to extract the number for the month from Date MonthNumber - str2num (Date (1:2)) To save typing, your program only needs to consider dates that are in the first half of the year January through June. You should also upload the final MatLab program to http://d2l.arizona.edu. (b) Add code to your program that prints out the number of the day in the year corresponding to the date the the user has entered. For example, if the user enters 03/12/2019, the progranm should print out "This is day number 71 of 2019" The number of days in cach of the first six months are: Jan 3, Feb - 28, Mar- 31, Apr-30, May 3, un-30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions