CS 172 Lab 3: Formatting Output
This is a lab exercise to help you learn how to format output using
Put and New_Line statements.
- Launch Windows Explorer. Remember
to set the View Options so that known file extensions are NOT
hidden. View your Y:\Ada subdirectory.
- Save the following file:
FormatOutput.adb
Save the file as Y:\Ada\FormatOutput.adb
View the directory
listing in Windows Explorer to confirm that the file is now in
your Y:\Ada subdirectory.
- Launch AdaGIDE. Open the file you just created,
Y:\Ada\FormatOutput.adb.
- This program is going to serve as a testbed to get you to learn to
format output in particular ways. The main body of the program
consists of a brief greeting followed by four groups of output
statements. At the top of each group of output statements is a
comment that tells you what the desired output sentence is. You
should modify the calls to Ada.Integer_Text_IO.Put and
Ada.Float_Text_IO.Put to make the actual output look exactly like the
desired output. Do not modify the Ada.Text_IO.Put or
Ada.Text_IO.New_Line statements.
- When you have made the modifications and are convinced that your
program produces its output in the format that is required, you should
redirect its output to a file so that you can print it. Do this by
choosing Run Options from the Run menu, typing the name of your output
file in the Output File box. You can name your output file anything
you like, but be aware that Ada will delete any previous file with the
same name, then store your output in a file with that name, so one
particularly bad choice for a file name is FormatOutput.adb.
When you have chosen a name, click on the Output to file box, and then click
on OK. Now when you run your program, the output will go to the file
that you named instead of to the screen.
- After running your program with its output redirected to a file,
open that file and print it. You can open the file using whatever
program you want. Probably the easiest thing to do is just to open it
in Ada GIDE. Choose Open from the File menu, then change the Files of
Type option at the bottom of the window to All Files (*.*) rather than
Ada files.
- When you are ready you should bring me:
- A printout of the listing (produced by Compile to Listing as in
previous labs) of your FormatOutput program.
- A printout of the output produced by your program.