Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

OUTPUT PROBLEMS

darkwave0darkwave0 Posts: 2Member
I'm having trouble with this check writer program. Here are the rules for writing the program. There can be [b]no global variables[/b], and the program must use [b]only procedures[/b] to be written in.

Here is the [b]code[/b]:




[b]procedure[/b] Hundreds(var amount : real; var amtaswords : string; var x, tens: integer);
var
hundreds : integer;
begin


hundreds := trunc(amount) div 100;

case hundreds of
1: amtaswords := amtaswords + 'ONE HUNDRED';
2: amtaswords := amtaswords +'TWO HUNDRED';
3: amtaswords := amtaswords +'THREE HUNDRED';
4: amtaswords := amtaswords +'FOUR HUNDRED';
5: amtaswords := amtaswords +'FIVE HUNDRED';
6: amtaswords := amtaswords +'SIX HUNDRED';
7: amtaswords := amtaswords +'SEVEN HUNDRED';
8: amtaswords := amtaswords +'EIGHT HUNDRED';
9: amtaswords := amtaswords +'NINE HUNDRED';

end;
x := trunc(amount) mod 1000;
Tens := x div 1000;
end;
{********************************************************************}
procedure tens(var amount : real; var amtaswords : string; var x, tens: integer);
var
ones : integer;

begin
tens := trunc(amount) div 10;
case tens of

2: amtaswords := amtaswords +'TWENTY';
3: amtaswords := amtaswords +'THIRTY';
4: amtaswords := amtaswords +'FOURTY';
5: amtaswords := amtaswords +'FIFTY';
6: amtaswords := amtaswords +'SIXTY';
7: amtaswords := amtaswords +'SEVENTY';
8: amtaswords := amtaswords +'EIGHTY';
9: amtaswords := amtaswords +'NINETY';

end;
x := trunc(amount) mod 1000;

ones := x div 100;
end;
{********************************************************************}
procedure ONES(var amount : real; var amtaswords : string; var x, tens: integer);
var
ones : integer;


begin
ones := trunc(amount) div 1;
case ones of
1: amtaswords := amtaswords +'ONE';
2: amtaswords := amtaswords +'TWO';
3: amtaswords := amtaswords +'THREE';
4: amtaswords := amtaswords +'FOUR';
5: amtaswords := amtaswords +'FIVE';
6: amtaswords := amtaswords +'SIX';
7: amtaswords := amtaswords +'SEVEN';
8: amtaswords := amtaswords +'EIGHT';
9: amtaswords := amtaswords +'NINE';

end;
x := trunc(amount) mod 1000;
end;
{********************************************************************}
procedure Output(amount : real; var amtaswords : string);
begin
writeln('***************************************************');
writeln('* #328 *');
writeln('* Bank of Biff *');
writeln('* 2300 E Baseline Rd *');
writeln('* Mesa AZ 85238 ',formatdatetime('mmmm yyyy',Now),' *');
writeln('* *');
writeln('* Amount $',amount:0:2,' ');
writeln('* *');
writeln('* ', [b]amtasword[/b]s,' *'); {<- OUTPUT}
writeln('* *');
writeln('* *');
writeln('* McArnold''s Burgers *');
writeln('* 258 S McQueen Rd *');
writeln('* Gilbert AZ 85233 ________________ *');
writeln('* *');
writeln('* *');
writeln('***************************************************');

end;

var
theamount: real;
words: string;
int1 : integer;
int2 : integer;

begin
data(theamount);
thousands(theamount, words, int1, int2);
hundreds(theamount, words, int1, int2);
tens(theamount, words, int1, int2);
ones(theamount, words, int1, int2);
Output(theamount, words);
readln;
[b]end.[/b]

----------------------------------------------------------------------
Ok, this is the output if you enter 1235.11:
----------------------------------------------------------------------

ONE THOUSAND

---------------------------------------------------------------------
What I want it to say is:
---------------------------------------------------------------------

ONE THOUSAND TWO HUNDRED THIRTY FIVE DOLLARS AND ELEVEN CENTS

---------------------------------------------------------------------

PLEASE HELP ME MODIFY THIS PROGRAM TO OUTPUT THE LATTER.

Comments

Sign In or Register to comment.