18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

Program 1-1.<br />

_______________________________________________________________________________<br />

for COUNT = 1 to NUMBER.OF.SEATS<br />

do<br />

read PASSENGER.NO, FARE, and BAGGAGE.WEIGHT<br />

let CHECK.SUM = ...<br />

if CHECK.SUM CHECK.VALUE<br />

go to 'CHECK.ERROR'<br />

otherwise<br />

if FARE = FIRST.CLASS.FARE<br />

add 1 to CHAMPAGNE.COUNT<br />

go to 'TOTALS'<br />

otherwise<br />

if FARE = EXECUTIVE.CLASS.FARE<br />

.<br />

.<br />

go to 'TOTALS'<br />

otherwise<br />

if FARE = ECONOMY.CLASS.FARE<br />

.<br />

.<br />

go to 'TOTALS'<br />

otherwise<br />

if FARE = STANDBY.FARE<br />

.<br />

.<br />

go to 'TOTALS'<br />

otherwise<br />

'TOTALS'<br />

add BAGGAGE.WEIGHT to TOTAL.WEIGHT<br />

add 1 to MEALS.REQUIRED<br />

loop<br />

let LOAD.FACTOR = (COUNT-1)/NUMBER.OF.SEATS<br />

.<br />

.<br />

'CHECK.ERROR'<br />

print 1 line with PASSENGER.NO thus<br />

ERROR IN TICKET NO. ******<br />

_______________________________________________________________________________<br />

The otherwise (or the synonym else) in this example could be replaced by always, endif<br />

or regardless with exactly the same meaning. This structure has been retained to provide<br />

compatibility with earlier versions of the <strong>SIMSCRIPT</strong> language. To clearly identify this anomaly<br />

in control structure, it is suggested that the otherwise synonym for else be reserved for this<br />

usage.<br />

28

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

Saved successfully!

Ooh no, something went wrong!