Copying, Pasting, and Deleting Text

The remainder of the program consists of the following printf statements. Don't type them in yet. You will copy and paste to enter these lines.

printf( "Number of years: %i\n", nper );

printf( "Monthly Payment: %f\n", pmt );

printf( "Total Payments: %f\n", pmt * nper * 12.0 );

printf( "Total Interest: %f\n", pmt * nper * 12.0 - pv );

Since these lines are similar, you can save time by typing only the first one, then copying and pasting text using PWB's clipboard (a temporary storage place for text).

·To copy and paste text:

1.Place the cursor on the line:

printf( "Interest rate: %f\n", rate );

2.From the Edit menu, choose Copy. This action places the entire line on the clipboard for later reference.

3.To insert the copied line, choose Paste from the Edit menu.

4.Paste the same line three more times to create enough printf statements for the remainder of the program.

Your screen should look like the following figure:

There are now five copies of the same printf statement. Next, you'll modify the printf statements so that each corresponds to the preceding example. The cursor should be on the first copy of the printf statement.

Before you modify the text, you must select what you are going to modify.

·To select text:

1.Point to the I in “Interest Rate” in the second printf statement.

2.While holding down the left mouse button, drag the mouse until it is over the colon.

The text Interest Rate is now selected and highlighted on your screen.

·To select this text with the keyboard:

1.Move the cursor to the first character of text you want to select.

2.Press SHIFT+RIGHT ARROW until the cursor is on the colon.

Now that the text is selected, type: Number of Years. When you type the first character, you'll notice that the selected text is deleted.

Important:

If you select an area of text and type, PWB replaces the selected text and does not save it on the clipboard. You can recover the text by choosing Undo from the Edit menu.

Now change the variable rate on the same line to nper, as follows:

1.Select the word rate and press DEL.

The word is removed from the file and placed on the clipboard. Pressing DEL is a direct way to delete text.

2.Type the word nper

Use the techniques you've learned to make the rest of the corrections, and then save the file by choosing Save from the File menu.

Note :

You can turn on automatic file saving by setting the Autosave switch to yes with the Editor Settings command on the Options menu. When Autosave is turned on, PWB automatically saves your file before executing certain commands such as running your program or switching to another file. For example, if you run a program that is not yet stabilized, PWB ensures that your file is stored safely in case you have to reboot.