Read the file a line at a time

Assignment Help MATLAB Programming
Reference no: EM13165187

Write a function called replaceStr. Your function should take in the following (in this order): filename: A string that corresponds to the name of a file wordA: A string that is a word (contains no spaces) wordB: Another string that is also a word (contains no spaces) Your function should do the following:

a.   Read the file a line at a time.

b.   On each line, replace every occurrence of wordA with wordB.

c.   Write the modified text file with the same name as the original file, but preprended with 'new_'. For instance, if the input filename was 'data.txt', the output filename would be 'new_data.txt'.

d.   Prepare a test file by downloading a text file from the Internet. For example, the complete works of Shakespeare are accessible at https://www.william-shakespeare.info

e.   Examine the file for repeated words and test your function by writing a script that replaces frequently repeated words.

You have to use the file below in order to write the program:

from Twelfth Night, Act 2 Scene 2

I left no ring with her: what means this lady?
Fortune forbid my outside have not charm'd her!
She made good view of me; indeed, so much,
That sure methought her eyes had lost her tongue,
For she did speak in starts distractedly.
She loves me, sure; the cunning of her passion
Invites me in this churlish messenger.
None of my lord's ring! why, he sent her none.
I am the man: if it be so, as 'tis,
Poor lady, she were better love a dream.
Disguise, I see, thou art a wickedness,
Wherein the pregnant enemy does much.
How easy is it for the proper-false
In women's waxen hearts to set their forms!
Alas, our frailty is the cause, not we!
For such as we are made of, such we be.
How will this fadge? my master loves her dearly;
And I, poor monster, fond as much on him;
And she, mistaken, seems to dote on me.
What will become of this? As I am man,
My state is desperate for my master's love;
As I am woman,--now alas the day!--
What thriftless sighs shall poor Olivia breathe!
O time! thou must untangle this, not I;
It is too hard a knot for me to untie!

 

Reference no: EM13165187

Questions Cloud

Consider the molar mass of nh : You prepared a 0.250 M solution by diluting 8.45(+-0.04)mL of 28.0(+-0.5)mL wt.%NH3 (density=0.899(+-0.003)g/mL up to 500.0(+-0.2)mL. Find the uncertainty in 0.250 M.
Make a c program using cramers rule using 3 variables and eq : make a C program using cramers rule using 3 variables and 3 equations. I need help why the third variable says it isnt initialized and allow the the determinents to be calculated. also i need help making a menu allowing the user to make a start the p..
Topics: user interface, input validation, computer security : Topics: user interface, input validation, computer security, i/o processing, storage & retrievalAssignment: Write a program that will simulate a basic registration/login process for a standard application or website.Menu ItemsCreate a profileAsk the ..
Calculate the molality, molarity : An aqueous antifreeze solution is 40.0% ethylene glycol (C2H6O2) by mass. The density of the solution is 1.05 g/cm3. Calculate the molality, molarity, and mole fraction of the ethylene glycol.
Read the file a line at a time : Write the modified text file with the same name as the original file, but preprended with 'new_'. For instance, if the input filename was 'data.txt', the output filename would be 'new_data.txt'.
What is the molecular weight of the hormone : An aqueous solution containing 21.6 mg of vasopressin in 100.0 mL of solution has an osmotic pressure at 25.0 oC of 3.70 mmHg. What is the molecular weight of the hormone?
Design a 4-bit register based on four d flip-flops : Design a 4-bit register based on four D flip-flops with three inputs I (4-bit), c (2-bit), and clk, and one output A (4-bit). The register can do four different operations depending on the value
Using the expand, guess, and verify method find closed : Using the expand, guess, and verify method find closed form solutions for the following recurrence relations.
Analyze the societal implications of using this process : Discuss in detail, one way in which atomic nuclear decay takes place. What is the significance of atomic nuclear decay? Analyze the societal implications of using this process.

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Determine the inputs, outputs, relevant formulas

determine the inputs, outputs, relevant formulas

  Implement the finite difference method

Write a computer program to implement the finite difference method. The program can be in any computer language that is available within the school. Set up the code to find the potential for a parallel plate capacitor in the box shown below, all dime..

  Write a program to compute a

Write a program to compute A. Test it with P = $55,000 and interest rate of 6.6% (i = 0.066). Compute results for n = 1, 2, 3, 4, and 5 and display the results as a table with headings and columns for n and A

  Calculate the geometric mean of numbers

Write a program to calculate the geometric mean of numbers entered by a user. The program should prompt the user to enter numbers and continue to accept the numbers until the user enters 999.

  Consider the predator-prey models

Consider the predator-prey models developed early part of the 20 th  century in which the number of predators and preys may be predicted using the pair of ODEs

  Elementary numerical methods and programming

Project involes determining the dynamics of the double pendulum with a sliding base. Each link is assumed to be of square cross section - MECH 3010: Elementary Numerical Methods and Programming

  Create a matrix of 5x6

Prepare a matrix of 5x6. with identical columns and rows ranging from 200 to 1000 in equal increments

  An efficient human identification using gait analysis

An Efficient Human Identification Using Gait Analysis, Apply specific approach for Pattern Recognition,Implement this approach in MATLAB,Compare and discuss the results with others.

  Determine the size for variables used in matlab program

If b=3, a=6 how many loops would the given program do? what will be the out put for z(4)? what would be size (in rows and columns) for variables z, i and b?

  Compare with the true value

compare with the true value of 6.737947 x 10 -3  . Use 20 terms to evaluate each series and compute true and approximate relative errors as terms are added.

  Kerfuffleboard is a game very much like shuffleboard

Kerfuffleboard is a game very much like Shuffleboard. Players take turns shooting disks at a trianglular scoring area. While the scoring areas are the same in shuffleboard and kerfuffleboard, a disk's contribution to a player's score will be calcu..

  Time domain design and analysis

To design a "custom" controller to reduce the vibrations of the seat and a PID controller to reduce the vibration of the seat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd