SRL Archive - NOTA

Something I came up with


All that is man

2009-08-29 23:52:32


{*******************************************************************************
function AddUpChange(pennies, nickles, dimes, quaters: integer): extended;
By: All that is man
Description: Adds up the USD 'change' and writelns it out and saves it to result
*******************************************************************************}
function AddUpChange(pennies, nickles, dimes, quaters: integer): extended;
var
i: integer;
total: extended;

begin
for i := 1 to pennies do total := total + 0.01;
for i := 1 to nickles do total := total + 0.05;
for i := 1 to dimes do total := total + 0.10;
for i := 1 to quaters do total := total + 0.25;
result := total;
Writeln('$'+FloatToStr(result));
end;

Lol, I was counting all my money, and I didn't feel like adding it up in my head.

AddUpChange(60, 13, 41, 59);
$20.1 :D

Thanks for all comments, and help!

senrath

2009-08-29 23:55:47

Result is an extended. You're trying to add a String and an Extended together, which doesn't work. Do Writeln('$' + FloatToStr(Result)); instead.

All that is man

2009-08-29 23:59:11

FloatToStr

Duh! :facepalm: I was trying ExtToStr haha

Rich

2009-08-30 00:50:01

Would you mind if I played around with it a little bit?

All that is man

2009-08-30 09:02:02

From: R1ch
Would you mind if I played around with it a little bit?


No bro go for it, have fun! As long as I get to see the final product :)

Narcle

2009-08-30 12:38:20

function AddUpChange(pennies, nickles, dimes, quarters: integer): extended;
begin
result := pennies*0.01+nickles*0.05+dimes*0.10+quarters*0.25;
Writeln('$'+FloatToStr(result));
end;

/bored

All that is man

2009-08-30 20:46:51

From: Narcle
function AddUpChange(pennies, nickles, dimes, quarters: integer): extended;
begin
result := pennies*0.01+nickles*0.05+dimes*0.10+quarters*0.25;
Writeln('$'+FloatToStr(result));
end;

/bored


Wow, you make me look dumb :(

Narcle

2009-08-30 20:52:41

From: All that is man
Wow, you make me look dumb :(

Sorry hehe, ur way is just unique. ;)

All that is man

2009-08-30 20:55:22

From: Narcle
Sorry hehe, ur way is just unique. ;)


:D I try my best, haha

HyperSecret

2009-08-30 21:28:25

From: All that is man
:D I try my best, haha


He is a Dev, that is his job ;). Good job though!

All that is man

2009-08-31 02:02:56

From: HyperSecret
He is a Dev, that is his job ;). Good job though!


Haha, thanks