25.06.2013 Views

Il Linguaggio Fortran 90/95

Il Linguaggio Fortran 90/95

Il Linguaggio Fortran 90/95

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.

262 Unità di Programma<br />

IMPLICIT NONE<br />

TYPE (money) :: addmoney<br />

TYPE (money), INTENT(IN) :: a, b<br />

INTEGER :: carry, tempcent<br />

tempcent = a%cent + b%cent<br />

carry = 0<br />

IF (tempcent>100) THEN<br />

tempcent = tempcent - 100<br />

carry = 1<br />

END IF<br />

addmoney%euro = a%euro + b%euro + carry<br />

addmoney%cent = tempcent<br />

END FUNCTION addmoney<br />

FUNCTION subtractmoney(a,b)<br />

IMPLICIT NONE<br />

TYPE (money) :: subtractmoney<br />

TYPE (money), INTENT(IN) :: a, b<br />

INTEGER :: euro, tempcent, carry<br />

tempcent = a%cent - b%cent<br />

euro = a%euro - b%euro<br />

IF ((tempcent0)) THEN<br />

tempcent = 100 + tempcent<br />

euro = euro - 1<br />

ELSE IF ((tempcent>0).AND.(euro

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

Saved successfully!

Ooh no, something went wrong!