I need help writing a program. First off I understand that no ones going to give me the code and thats good... don't want an F or worse kicked out of university. I'll give my source code and a description of whats going on and some times I can't figure out how to make ada do. I'm writing in ADA 95 and using the AdaGIDE v 6.30.3.

I need to write a program to calculate the irrational number E to a user inputed exponent. I need to have data validation so that the exponent inputed is an integer and in the range of -8 to 8. I need to freeze the output from the executable (which is already working in my code) so that it doesn't just go right off the screen when its done running. I need to compare the value of e to the "x" with that of ADA's own value calculated based on its Ada.Numerics_Elementary_Functions package.

There needs to be a procedure to prompt for and get an integer from the user. This procedure works.

There needs to be a function to calculate e to the user inputed integer to an accuracy of 6 significant figures

Which the directions say to stop adding new terms when the absolute value of the new term calculated is less then one millionth of the size of the sum so far. To not add that term.

Then a procedure to display the results on the screen.

The first problem I'm having is I can't figure out how to get ADA to produce the value of E to the screen from its Numerics_Elementary_Functions package...

I don't think it can hurt to give me the code for that....

Just to say something like

Ada.Numerics.Elementary_Functions.Put (Item => E); or .Put ( Item => E ** exp);

in the latter case exp is the variable I created to store the integer the user wishes to use as the exponent of E

I can't even get ada to print out the value of E so far.

So basically the display procedure and the get_exponent procedures are done and working with the exception of having to code the data validation which is as easy as declaring a range on the values of the integer variable exp and setting up and exception handler for the even that they hit a letter or some crap.

Here's my code so far:

Telling me how to get ADA to print the value of E or do calculations with it, like I said how do I print to the screen the value of E that ADAs numerics package gives. With that I can correct my display procedure and in the mean while I'll write my own function for calculating the value of e and put the exception handler in the first procedure.

I think my only other snag up might be in the whole if the absolute value is less then one one millionth of the value of the sum so far to not add it.

Thanks in advance for whatever help I can get.

I need to write a program to calculate the irrational number E to a user inputed exponent. I need to have data validation so that the exponent inputed is an integer and in the range of -8 to 8. I need to freeze the output from the executable (which is already working in my code) so that it doesn't just go right off the screen when its done running. I need to compare the value of e to the "x" with that of ADA's own value calculated based on its Ada.Numerics_Elementary_Functions package.

There needs to be a procedure to prompt for and get an integer from the user. This procedure works.

There needs to be a function to calculate e to the user inputed integer to an accuracy of 6 significant figures

Which the directions say to stop adding new terms when the absolute value of the new term calculated is less then one millionth of the size of the sum so far. To not add that term.

Then a procedure to display the results on the screen.

The first problem I'm having is I can't figure out how to get ADA to produce the value of E to the screen from its Numerics_Elementary_Functions package...

I don't think it can hurt to give me the code for that....

Just to say something like

Ada.Numerics.Elementary_Functions.Put (Item => E); or .Put ( Item => E ** exp);

in the latter case exp is the variable I created to store the integer the user wishes to use as the exponent of E

I can't even get ada to print out the value of E so far.

So basically the display procedure and the get_exponent procedures are done and working with the exception of having to code the data validation which is as easy as declaring a range on the values of the integer variable exp and setting up and exception handler for the even that they hit a letter or some crap.

Here's my code so far:

Code:

With Ada.Text_IO; With Ada.Integer_Text_IO; With Ada.Float_Text_IO; With Ada.Numerics.Elementary_functions; Procedure e_to_the_x is -- -------------------------------------------------------- -- Program Name: e_to_the_x -- Purpose: This program gathers an integer from the user, a -- desired power of the irrational term E, and calculates E to -- that power. Then it compares the value of my function to -- ADA's numerics package. E is calcuated to a percision of -- 6 signifcant figures in my function. Then a post test loop -- asking the user to continue and a data validation feature -- -------------------------------------------------------- ----------------------------------------------------------- Procedure Get_Exp (Exp : OUT Integer) is Begin -- Get_Exp Ada.Text_IO.Put (Item => "Enter an integer from -8.0 to 8.0: "); Ada.Integer_Text_IO.Get (Item => Exp); End Get_Exp; ----------------------------------------------------------- -- Function Exponential (Exp : In Integer) return float is -- -- Begin Exponential; -- -- -- -- Return Sum ; -- -- End Exponential ; ----------------------------------------------------------- -- Procedure Display_Sum (Sum: In Float; Exp: In Integer) is -- -- Begin Display_Sum; -- -- -- Put (Item => "Approximation of e to the "); -- Put (Item => Exp); -- Put (Item => " power is: "); -- Put (Item => Sum); -- -- New_Line; -- -- Put (Item => "Value produced by Ada's exp function is: "); -- Put (Item => e ** Exp); -- -- End Display_Sum; ----------------------------------------------------------- Exp: Integer ; Sum: Float ; Letter: String(1..1); choice: Integer ; Begin Loop Get_Exp(Exp); Ada.Text_IO.Put (Item => "Do you wish to continue? (1 - Yes, 2 - No): "); Ada.Integer_Text_IO.Get (Item => choice); exit when choice = 2 ; End Loop; Ada.Text_IO.Put (Item => "Type a letter and hit enter to exit program: "); Ada.Text_IO.Get (Item => Letter); End e_to_the_x ;

Telling me how to get ADA to print the value of E or do calculations with it, like I said how do I print to the screen the value of E that ADAs numerics package gives. With that I can correct my display procedure and in the mean while I'll write my own function for calculating the value of e and put the exception handler in the first procedure.

I think my only other snag up might be in the whole if the absolute value is less then one one millionth of the value of the sum so far to not add it.

Thanks in advance for whatever help I can get.

*Last edited by shabbir; 6Apr2009 at 08:33.. Reason: Code block*