| | |
Formatting "Buzz - Fizz" Game, help!
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: May 2005
Posts: 2
Reputation:
Solved Threads: 0
Hey people! Ive had to right a simulation to the game buzz-fizz..this is what the game is... One person starts of by calling out '1' then each player adds one to the previous players number and calls out that number unless it divides excatly by three or five.. If it divides by three he calls out "Buzz" and if it divides by five he calls out "fizz" instead of the number. If it divides by both three and five he calls out "buzz-fizz".
Now then the problem i'm having is the formatting of it!
This is my code for the game:
program BuzzFizz (input,output);
uses
crt;
var
number : integer;
begin {main program};
Clrscr;
for number := 1 to 100 do
begin
if (number mod 5 = 0) and (number mod 3 = 0 )
then begin
writeln (' ' , "Buzz - Fizz!", ' ')
end
else begin
if number mod 3 = 0
then begin
writeln (' ' , "Buzz!", ' ')
end;
if number mod 5 = 0
then begin
writeln (' ' , "Fizz!", ' ')
end;
if (number mod 5 <> 0) and (number mod 3 <> 0)
then begin
write (' ' , number:10, ' ');
end;
end;
end;
end.
Can someone please help me so that its readable on the screen and set out nicely..dont really have a clue about formatting
Now then the problem i'm having is the formatting of it!
This is my code for the game:
program BuzzFizz (input,output);
uses
crt;
var
number : integer;
begin {main program};
Clrscr;
for number := 1 to 100 do
begin
if (number mod 5 = 0) and (number mod 3 = 0 )
then begin
writeln (' ' , "Buzz - Fizz!", ' ')
end
else begin
if number mod 3 = 0
then begin
writeln (' ' , "Buzz!", ' ')
end;
if number mod 5 = 0
then begin
writeln (' ' , "Fizz!", ' ')
end;
if (number mod 5 <> 0) and (number mod 3 <> 0)
then begin
write (' ' , number:10, ' ');
end;
end;
end;
end.
Can someone please help me so that its readable on the screen and set out nicely..dont really have a clue about formatting
•
•
Join Date: Jan 2005
Posts: 9
Reputation:
Solved Threads: 0
First, strings in Pascal are delimited with single quotes ('), not double quotes (").
Second, you can consolidate your writelns into one string
from
writeln(' ', 'Buzz', ' ');
to
writeln(' Buzz ');
Finally, if you change the final write to writeln, change the width specifier to 5, change 'Buzz - Fizz' to 'Buzz-Fizz', it comes out looking a lot better.
HTH
Daaave
Second, you can consolidate your writelns into one string
from
writeln(' ', 'Buzz', ' ');
to
writeln(' Buzz ');
Finally, if you change the final write to writeln, change the width specifier to 5, change 'Buzz - Fizz' to 'Buzz-Fizz', it comes out looking a lot better.
HTH
Daaave
![]() |
Similar Threads
- "Free Roam" Game Suggestions? (Geeks' Lounge)
- Difficult progression playing "Hitman codename 47" (Geeks' Lounge)
- Mail Formatting lost when sending from Panther "mail" app. (Mac Software)
- Offline Games like "Anarchy Online"? (Geeks' Lounge)
- "no adapter found" (Windows NT / 2000 / XP)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Delphi Pascal Error
- Next Thread: Delphi Help
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi





