12.07.2015 Views

page-1983-101-timex-sinclair-programming-tricks

page-1983-101-timex-sinclair-programming-tricks

page-1983-101-timex-sinclair-programming-tricks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ending in 95 cents. For instance, a ten dollar item mightbe marked $9.95 or $10.95.Here's a program which demonstrates how to makeall prices come out to the nearest 95 cents. See line 40. Itmerely takes the integer portion of the dollars numberand adds 0.95 to it.Program Usting10 LET P=g20 PRINT •MANUFACTURING COST:"25 INPUT C30 PRINT "PRICING MULTIPLIER:•35 INPUT M40 LET P=INT (C*M)+0.9550 CLS60 PRINT •RETAIL PRICE: $";P70 PRINT80 GOTO 1071 To the Nearest PennyThis program is useful when you have a dollar-andcentsfigure with more than two decimal places. For example,$151.6972. You need to transform $151.6972 to themore common $151.70This small program would make a good subroutine ina larger set of instructions. To do so, insert GOSUB at theappropriate place in the larger set of program lines.Modify the line numbers of this small program so thesubroutine will be located in an unused position in thelarger listing. Change the last line of this small program toRETURN.Program Listing10 LET R=g20 PRINT •ENTER A NUMBER TO"30 PRINT "MORE THAN TWO DECIMAL PLACES"91

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!