Distance With Errors Listing File-Aeronautical Engineering And Computer Programming-Assignment Solution, Exercises of Aeronautical Engineering

This is solution to assignment for Aeronautical Engineering and Computer Programming course. It was submitted to Prof. Chitraksh Gavde at Biju Patnaik University of Technology, Rourkela. It includes: Algorithm, Distance, Listing, Error, Procedure, Ada, Natural, Float, Compute, Begin, Bug, Fix

Typology: Exercises

2011/2012

Uploaded on 07/20/2012

savitri_122
savitri_122 🇮🇳

4.6

(14)

184 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
C3 Solutions
1. Distance_With_Errors Listing File
Compiling: c:/docume~2/joeb/desktop/adatex~1/fk3-w95/distance_with_errors.adb (source file time stamp:
1998-09-13 23:11:36)
1. WITH Ada.Text_IO;
2. WITH Ada.Float_Text_IO;
3. PROCEDURE Distance_with_Errors IS
4. --------------------------------------------------------------
5.
6.
7.
8. --------------------------------------------------------------
9. HowLong : Natural;
10. HowFast : Float;
11. HowFar : Natural;
12.
13. BEGIN -- Distance_with_Errors
14.
15. -- prompt user for hours and average speed
16. Ada.Text_IO.Put
17. (Item => "How long will you be driving (integer) ? ");
18. Ada.Float_Text_IO.Get (Item => HowLong);
|
>>> invalid parameter list in call (use -gnatf for details)
19. Ada.Text_IO.Put
20. (Item => "At what speed (miles per hour, integer)?");
21. Ada.Float_Text_IO.Get (Item => HowFast);
22.
23. -- compute distance driven
24. HowFast := HowLong * HowFar;
|
>>> expected type "Standard.Float"
>>> found type "Standard.Integer"
25.
26. -- display results
27. Ada.Text_IO.Put (Item => "You will travel about ");
28. Ada.Float_Text_IO.Put (Item => HowFar);
|
>>> invalid parameter list in call (use -gnatf for details)
>>> possible missing instantiation of Text_IO.Integer_IO
29. Ada.Text_IO.Put (Item => " miles");
30. Ada.Text_IO.New_Line;
31.
32. END Distance_with_Errors;
33.
33 lines: 5 errors
2. Distance_With_Errors with bug fixes
docsity.com
pf3
pf4

Partial preview of the text

Download Distance With Errors Listing File-Aeronautical Engineering And Computer Programming-Assignment Solution and more Exercises Aeronautical Engineering in PDF only on Docsity!

C3 Solutions

1. Distance_With_Errors Listing File

Compiling: c:/docume~2/joeb/desktop/adatex~1/fk3-w95/distance_with_errors.adb (source file time stamp: 1998-09-13 23:11:36)

  1. WITH Ada.Text_IO;
  2. WITH Ada.Float_Text_IO;
  3. PROCEDURE Distance_with_Errors IS


  4. HowLong : Natural;
  5. HowFast : Float;
  6. HowFar : Natural;
  7. BEGIN -- Distance_with_Errors
  8. -- prompt user for hours and average speed
  9. Ada.Text_IO.Put
  10. (Item => "How long will you be driving (integer)? ");
  11. Ada.Float_Text_IO.Get (Item => HowLong); |

invalid parameter list in call (use -gnatf for details)

  1. Ada.Text_IO.Put
  2. (Item => "At what speed (miles per hour, integer)?");
  3. Ada.Float_Text_IO.Get (Item => HowFast);
  4. -- compute distance driven
  5. HowFast := HowLong * HowFar; |

expected type "Standard.Float" found type "Standard.Integer"

  1. -- display results

  2. Ada.Text_IO.Put (Item => "You will travel about ");

  3. Ada.Float_Text_IO.Put (Item => HowFar); |

invalid parameter list in call (use -gnatf for details) possible missing instantiation of Text_IO.Integer_IO

  1. Ada.Text_IO.Put (Item => " miles");
  2. Ada.Text_IO.New_Line;
  3. END Distance_with_Errors;

33 lines: 5 errors

2. Distance_With_Errors with bug fixes

GNAT 3.13p (20000509) Copyright 1992-2000 Free Software Foundation, Inc.

Compiling: c:/docume~2/joeb/desktop/adatex~1/fk3-w95/distance_with_errors.adb (source file time stamp: 2003-09-10 10:41:38)

. WITH Ada.Text_IO; . with Ada.Float_Text_Io; . with Ada.Integer_Text_IO; . PROCEDURE Distance_with_Errors IS . -------------------------------------------------------------- . --| Finds distance, given travel time and average speed . --| Author: Michael eldman, The George Washington University . --| Last Modified: June 1998 . -------------------------------------------------------------- . HowLong : Natural; . HowFast : Float; . HowFar : Natural; . . BEGIN -- Distance_with_Errors . . -- prompt user for hours and average speed . Ada.Text_IO.Put . (Item => "How long will you be driving (integer)? "); . Ada.Integer_Text_IO.Get (Item => HowLong); . Ada.Text_IO.Put . (Item => "At what speed (miles per hour, integer)?"); . Ada.Float_Text_IO.Get (Item => HowFast); . . -- compute distance driven . HowFar:= HowLong * Integer(HowFast); . . -- display results . Ada.Text_IO.Put (Item => "You will travel about "); . Ada.Integer_Text_IO.Put (Item => HowFar); . Ada.Text_IO.Put (Item => " miles"); . Ada.Text_IO.New_Line; . . END Distance_with_Errors; .

34 lines: No errors

4. Code listing of the implementation of the algorithm.

GNAT 3.13p (20000509) Copyright 1992-2000 Free Software Foundation, Inc.

Compiling: c:/docume~2/joeb/desktop/16070/concep~1/convert_weight.adb (source file time stamp: 2003- 09-10 18:46:40)

. ---------------------------------------------------- . -- Program : To Convert the user weight in kilograms . -- into pounds. . -- Programmer : Joe B . -- Date Last Modified : 09/10/ . ------------------------------------------------------ . . . with Ada.Text_Io; . with Ada.Float_Text_Io; . . procedure Convert_Weight is . . Weight_In_Kg, Weight_In_Lb : Float; . -- set the conversion factor to convert between kilograms and pounds . Conversion_Factor : constant Float := 0.453592; . . begin -- Convert_Weight . -- get user input . Ada.Text_Io.Put(Item => "Please Enter Your Weight in Kilograms "); . Ada.Float_Text_Io.Get(Item => Weight_In_Kg); . Ada.Text_Io.Skip_Line; . . Ada.Text_Io.New_Line; . -- perform the conversion . Weight_in_lb := Weight_in_Kg / Conversion_Factor; . . -- display the computed result to the user . Ada.Float_Text_Io.Put(Item => Weight_In_Kg, Fore => 4, Aft => 3, Exp => 0); . Ada.Text_Io.Put(Item => " kg = "); . . Ada.Float_Text_Io.Put(Item => Weight_In_lb, Fore => 4, Aft => 3, Exp => 0); . Ada.Text_Io.Put(Item => " lb"); . . end Convert_Weight;

35 lines: No errors