Objective : To learn to format the output of a given program. Problem : The following program reads the length and height of three rooms and displays the total square feet and the average area of the rooms. Task : To modify this program so that it prints the total square feet rounded to the nearest tenth of a square foot and the average is rounded to the nearest hundredth of a square foot.
Cut and paste the program from this WWW page into the ADA IDE.
with Ada.Text_Io,Ada.Integer_Text_Io,Ada.Float_Text_Io; use Ada; procedure Area is Len1:Float; width1 :Float; Len2:Float; width2 :Float; Len3:Float; width3 :Float; Area :Float; Avarea : Float; begin Text_Io.Put("Enter the length of the first room: "); Float_Text_Io.Get(Len1); Text_Io.Put("Enter the width of the first room: "); Float_Text_Io.Get(width1); Text_Io.Put("Enter the length of the Second room: "); Float_Text_Io.Get(Len2); Text_Io.Put("Enter the width of the second room: "); Float_Text_Io.Get(width2); Text_Io.Put("Enter the length of the third room: "); Float_Text_Io.Get(Len3); Text_Io.Put("Enter the width of the third room: "); Float_Text_Io.Get(width3); Area:= (Len1*width1 + Len2*width2 + Len3*width3); Avarea:= (Area/3.0); Text_Io.Put("The sum of the areas of the roons are: "); Float_Text_Io.Put(Area); Text_Io.New_Line; Text_Io.Put("The average of the areas of the rooms are: "); Float_Text_Io.Put(Avarea); end Area;
Example Input :If the total area of the rooms is 1223.342 The output should be --> 1223.3 If the average total area is 1445.342 The ouput should be -->1445.34 Hint : Example
Objective : To learn to write expressions. Problem : To write a program that calculates the interest for an amount invested for a particular period of time. Task : a.To write an ADA program that reads 1.Amount of money invested ( P )(float) 2.The interest rate in percent ( i )(float) 3.The number of years for which interest is to be calculated ( n )(integer) 4.The number of times per year interest is compounded ( q )(integer) b.To compute the interest using the following formula and displaying it. Formula: A = P ( 1 + i/q)nq Output : The program output should print "The total amount of interest is : " Hint : The operator "To the power of " is **
Dr.Stansifer <ryan@cs.fit.edu> Rishi Gupta(G.S.A) <rgupta@cs.fit.edu> Last modified: Sat Jan 31 15:19:11 EST 1999Problem : People who deal with historical dates use a number called the Julian Day in calculating the number of days between two events.The Julian days is the number of days that have elapsed since January 1,4713 B.C. Task : To calculate the Julian Days from the given date entered by the user. Input : The program should ask the user the 1.Day (d) 2.Month (m) 3.Year (y) Formula : i = ( 1461 * ( y + 4800 + ( m - 14 ) / 12 ) ) / 4 j = ( 367 * ( m - 2 - 12 * ( ( m - 14 ) / 12 ) ) ) / 12 k = i+j l = ( 3 * ( ( y + 4900 + ( m - 14 ) / 12 ) / 100 ) ) / 4 Julian Days=k-l+d - 32075