From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_50,HK_RANDOM_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5bcb179dc8f1d423,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-14 13:58:21 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: cptnben@gisco.net (Ben) Newsgroups: comp.lang.ada Subject: Formatting output Date: 14 Nov 2001 13:58:21 -0800 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 24.169.107.241 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1005775101 30896 127.0.0.1 (14 Nov 2001 21:58:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 14 Nov 2001 21:58:21 GMT Xref: archiver1.google.com comp.lang.ada:16545 Date: 2001-11-14T21:58:21+00:00 List-Id: I am using the Linux version of the GNAT Ada compiler. I am trying to format a floating point output from Scientific Notation to a US currency standard. I am new to Ada and the only library I am using is TEXT_IO. I don't know for certain what I have available for other libraries. How might one make the following code (simple program) output the final results (TotFly and TotDri) as U.S. currency. Thanks, Ben with TEXT_IO, FLOAT_TEXT_IO; use TEXT_IO, FLOAT_TEXT_IO; procedure LAB01 is -- Programmer: Benjamin Hodge -- Date Due: Thursday, September 16 1999 -- FileName: lab01.adb -- Project Number: Project01 -- Project Description: -- This program is to be used to calculate the total -- costs for a trip to Florida, using given figures, with -- the options of driving or flying. The program will -- calculate and then display the total cost for each -- option, allowing a vacationer to choose the least -- expensive option. FuelPrice : float := 1.359; -- $ 1.359 per gallon RoomPrice : float := 49.95; -- $49.95 per night TicketPrice : float := 245.76; -- $245.76 per person CarRentPrice : float := 67.5; -- $ 67.50 per day MealPrice : float := 7.5; -- $ 7.50 per person/per meal MealNum : float := 27.0 ; -- 27 meals per person NumPeople : float := 2.0; -- Two people MilToFla : float := 1800.0; -- 1800 miles one - way SightCMil : float := 30.0; -- 30.0 miles per - day SightCFly : float := 8.0; -- 8 sight seeing days if flying SightCDri : float := 6.0; -- 6 sight seeing days if driving RentalMPG : float := 32.0; -- 32 miles Per Gallon MilesTravD : float; -- Total, driving MilesTravF : float; -- Total, flying FuelCostD : float; -- Total FuelCostF : float; -- Total FoodCost : float; -- Total RoomCost : float; -- Total RentalCost : float; -- Total TicketCost : float; -- Total TotFly : float; -- Total cost of flying TotDri : float; -- Total cost of driving begin -- Calculate Total Miles Traveled Driving MilesTravD := (MilToFla*2.0) + (SightCDri*SightCMil); -- Calculate Total Miles Traveled Flying MilesTravF := SightCFly*SightCMil; -- Calculate Total Fuel Cost driving FuelCostD := MilesTravD/(RentalMPG*FuelPrice); -- Calculate Total Fuel Cost flying FuelCostF := MilesTravF/(RentalMPG*FuelPrice); -- Calculate Total Food Cost FoodCost := MealNum*NumPeople*MealPrice; -- Calculate Total Room Cost RoomCost := RoomPrice*9.0; -- Calculate Total Rental Car Price RentalCost := CarRentPrice*9.0; -- Calculate Total Plane Ticket Cost TicketCost := TicketPrice*NumPeople; -- Calculate Total Cost of Flying TotFly := FuelCostF + RentalCost + RoomCost + FoodCost + TicketCost; -- Calculate Total Cost of Driving TotDri := FuelCostD + RentalCost + RoomCost + FoodCost; -- Display Results put ("Total Cost of Trip, flying : "); put(TotFly'img); NEW_LINE; put ("Total Cost of Trip, driving : "); put(TotDri'img); NEW_LINE; end LAB01;