Urgent!!! Please post the whole program! Given the following ADA program: -- Ada Example Program -- Input: An integer,

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Urgent!!! Please post the whole program! Given the following ADA program: -- Ada Example Program -- Input: An integer,

Post by answerhappygod »

Urgent!!! Please post the whole program!

Given the following ADA program:
-- Ada Example Program
-- Input: An integer, List_Len, where List_Len is less than
100,
-- followed by List_Len-integer values
-- Output: The number of input values that are greater than
the
-- average of all input values
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure jdoodle is
type Int_List_Type is array (1..99) of Integer;
Int_List : Int_List_Type;
List_Len, Sum, Average, Result : Integer;
Integer_File : File_Type;
function Minimum (List:Int_List_Type; len: Integer) return Integer
is
min:Integer;
begin
min := List(1);
for Index in 2 .. len loop
if min > List(Index) then
min := List(Index);
end if;
end loop;
return min;
end Minimum;
begin
Result := 0;
Sum := 0;
-- Open(Integer_File, In_File, "input.txt");
Get (List_Len);
-- skip_line(Integer_File);
if (List_Len > 0) and (List_Len < 100) then
-- Read input data into an array and compute the sum
for Counter in 1 .. List_Len loop
Get ( Int_List(Counter));
-- skip_line(Integer_File);
Sum := Sum + Int_List(Counter);
end loop;
-- Compute the average
Average := Sum / List_Len;
-- Count the number of values that are > average
for Counter in 1 .. List_Len loop
if Int_List(Counter) > Average then
Result := Result + 1;
end if;
end loop;
-- Print result
Put ("The number of values > average is:");
Put (Result);
New_Line;
Put ("The average is ");
Put (Average);
New_line;
else
Put_Line ("Error-input list length is not legal");
end if;
Result := Minimum(Int_List, List_Len);
Put("Minimum value is ");
Put(Result);
New_Line;
-- Close(Integer_File);
end jdoodle;
Data file to test with:
5
7
18
9
3
44
Change the program to just do a bubble sort and print out the
sorted array. Note, there is a Boolean data type that you can set
the Boolean variable to True or False. You can also use New_Line to
have the display go to the next line and can use the construct of
while cond loop/end loop;
Here is the code for bubblesort function:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply