Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 927807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:54:39+00:00 2026-05-15T19:54:39+00:00

I have a modified textbook example as follows (the book is Understanding Ada—a software

  • 0

I have a modified textbook example as follows (the book is Understanding Ada—a software engineering approach by Bray and Pokrass):

PACKAGE SOLAR_SYSTEM IS

 TYPE PLANET IS (MERCURY, VENUS, MARS, JUPITER, SATURN, NEPTUNE);

 SUBTYPE TERRESTRIAL_PLANET IS PLANET RANGE MERCURY..MARS;
 SUBTYPE JOVIAN_PLANET IS PLANET RANGE JUPITER..NEPTUNE;

 TYPE MILES IS DIGITS 5 RANGE 0.0..5.0E9;
 TYPE PLANET_FACTS IS ARRAY (PLANET) OF MILES;

 DISTANCE_TO_SUN : CONSTANT PLANET_FACTS :=
  (MERCURY => 36.0E6, VENUS => 67.2E6, MARS => 141.7E6,
  JUPITER => 484.0E6, SATURN => 887.0E6, NEPTUNE => 2797.0E6);

 NUMBER_OF_MOONS: CONSTANT ARRAY (PLANET) OF NATURAL :=
  (MERCURY => 0, VENUS => 0, MARS => 2,
  JUPITER => 12, SATURN => 10, NEPTUNE => 2);

END SOLAR_SYSTEM;

Now to access some variables and their contents,

WITH Ada.Float_Text_IO;
WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;
WITH SOLAR_SYSTEM;
USE SOLAR_SYSTEM;


PROCEDURE TEST2 IS

BEGIN -- main program
  Ada.Integer_Text_IO.Put(Item => NUMBER_OF_MOONS(Saturn));
  Ada.Text_IO.New_Line;
  Ada.Float_Text_IO.Put(Item => DISTANCE_TO_SUN(Saturn));
END TEST2;

I can access NUMBER_OF_MOONS(Saturn) without any problem but I have difficulty to access
DISTANCE_TO_SUN(Saturn). How to access it?

thanks a lot…

This is what I get on compilation with the statement

Ada.Float_Text_IO.Put(Item => DISTANCE_TO_SUN(Saturn));

list file:

1. WITH Ada.Float_Text_IO;
            |
    >>> warning: no entities of "FLOAT_TEXT_IO" are referenced

 2. WITH Ada.Text_IO;
 3. WITH Ada.Integer_Text_IO;
 4. WITH SOLAR_SYSTEM;
 5. USE SOLAR_SYSTEM;
 6.
 7.
 8. PROCEDURE TEST2 IS
 9.
10.    BEGIN -- main program
11.     Ada.Integer_Text_IO.Put(Item => NUMBER_OF_MOONS(Saturn));
12.     Ada.Text_IO.New_Line;
13.     Ada.Float_Text_IO.Put(Item => DISTANCE_TO_SUN(Saturn));
                         1            5
    >>> no candidate interpretations match the actuals:
    >>> missing argument for parameter "To" in call to "PUT" declared at a-tiflio.ads:81, instance at a-flteio.ads:20
    >>> missing argument for parameter "File" in call to "PUT" declared at a-tiflio.ads:63, instance at a-flteio.ads:20
    >>> possible missing instantiation of Text_IO.Float_IO
    >>> expected type "Standard.Float"
    >>> found type "MILES" defined at solar_system.ads:8
    >>>   ==> in call to "Put" at a-tiflio.ads:70, instance at a-flteio.ads:20

14.    END TEST2;

The problem is that DISTANCE_TO_SUN(Saturn) is of type MILES which is one of the floating point types. So just using Ada.Float_Text_IO.Put won’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:54:39+00:00Added an answer on May 15, 2026 at 7:54 pm

    The problem is that you’ve declared a brand new type, MILES, which is “float-like”, but is not the predefined float type. So when you try to Put an item of that type, i.e. DISTANCE_TO_SUN(Saturn), there’s no Put procedure available for that type.

    You have three primary choices:

    1) Instantiate Float_Text_IO with the Miles type:

     package Miles_IO is new Ada.Text_IO.Float_IO(Solar_System.Miles);
    

    and then use Miles_IO to output the value:

     Miles_IO.Put(DISTANCE_TO_SUN(Saturn));
    

    2) Change the definition of miles to be a constrained subtype of Float:

    SUBTYPE MILES IS FlOAT RANGE 0.0..5.0E9;
    

    Then the original Float_Text_IO.Put will work just fine.

    3) Since Miles is a floating point type, you can convert it before Putting it:

     Ada.Float_Text_IO.Put(Item => Float(DISTANCE_TO_SUN(Saturn)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have modified my etc/hosts file (under Windows 7), so that www.example.com and demo.example.com
I have modified the MSDN example to reflect my problem. When using a namespace
I have modified my treeview to look like an Org chart using the example
I have modified the example found here to use two io channels. None of
I have modified the guestbook example shipped with google app engine (java) to include
I have modified my code, I am making a decoder that decodes as follows:
I have modified this example from the SDK pages to grab all the Contact
I have modified a slider script to mimic ebay's slider on home page. I
I have modified the Nerd Dinner application to allow editing of child records by
I have modified my MOSS 2007 configuration to query a given target AD successfully.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.