EZ Math Movie, Language, Printing


Printing

clearPrinter()

This command erases all printing on the printer. It is often used in the before loop code to insure that the printer is fresh and ready to go at the start of each program run. Here is an example of its use:

clearPrinter();

Tutorial: Printing a number

print('text')

This command sends text to the printer. The text will appear on the current printer line, and the text will wrap if it exceeds the width of the printer. A new line will not be printed after the text, so the printer stays on the same line upon which it started. Here is an example of how to use this command:

print('Learn math by programing math.');

The above code would print the text 'Learn math by programing math' on the printer.

Tutorial: Printing text

printNewLine()

This command sends the printer to the start of the next line. It is handy to move the printing to the next line after using the print and printNumber commands, since these commands do not create new lines after they output. Here is how to use printNewLine:

print('First line');
printNewLine();
print('Second line');

The above code would produce the following output on the printer:

First line
Second line

Tutorial: Printing a new line

printNumber(n)

This command outputs a number on the printer that is rounded to the current number of decimal places. The current number of decimal places defaults to 2, but this can be changes with the setNumDecimals command. The printNumber command works this way:

printNumber(1.115);

The above code would produce the following output on the printer:

1.12

Tutorial: Printing a number

printStatement('prefix', n, 'suffix')

This command provides a shorthand way to print a common type of math statement. For example, the following code:

printStatement('The height is ', h, ' meters.');

Would place the following text on the printer, provided that the variable h held a value of 6:

The height is 6 meters.

 

The last parameter, 'suffix', can be skipped. So the following code:

printStatement('x = ', x);

Would produce the following printing, assuming that the variable x held a value of 7:

x = 7

Tutorial: Printing text and numbers

setNumDecimals(numDecimals)

This command sets the maximum number of decimals for numeric value output. The last digit printed is rounded.  It works like this:

setNumDecimals(3);

The above code would set all rounded numeric values to be printed to 3 decimal places. So this code:

setNumDecimals(3);
printNumber(1.1115);
printNewLine();
printNumber(1.1114);

Would print this:

1.112
1.111

All contents of EZ Math Movie are copyrighted: Copyright 2011, Edward A. Zobel. All rights reserved.



Other sites you may find interesting

Zona Land Education Like Math and Physics?

Zona Land Education offers explanations, diagrams, and animations on these topics.
And it is all presented in a clear and casual manner.

Here is the link: zonalandeducation.com




EZ Programing Demos Want to learn about programing computers?

EZ Programing Demos has an animated, slow motion, interactive programing language demonstrator.
The site presents basic ideas at a beginner's level.

Here is the link: ezprogramingdemos.com



Custom Search