Objective : To introduce the conditional statement "IF-THEN-ELSE"
Task : To write an Ada program that read a year and outputs the month and day for Easter Sunday in that year.
Condition : The year should be between 1982 and 2048.
Given : The following formula caluclates the EASTER SUNDAY for the year.
A is Year rem 19
B is Year rem 4
C is Year rem 7
D is (19 * A + 24) rem 30
E is (2 * B + 4 * C + 6 * D + 5) rem 7
EASTER SUNDAY is MARCH (22 + D + E)
Note :This formula can give a date in April as well.If the value of 22+D+E is greater then 31 then the month is April
and the date is value minus 31
Output : The program should ask the user to enter the year
Enter the year (for example,1994) : 1995
The output should be
Easter is Sunday, March(or April) 7,in 1995
Helpful Stuff :Example of If statement.
Part 2
Task : To write an Ada program that takes as input the temperature and wind speed and calculates the wind chill in integer.
The wind chill is equal to the temperature if the wind speed is less than 4.If wind speed is greater than or equal
to 4 and less than or equal to 45 then the wind chill is
x=10.45 + 6.65 * Sqrt(wind_speed) -0.447*(wind_speed)
y=9.14 -(temperature)/22.0
wind_chill= (91.4-x*y)
If the wind speed is greater than 45 then the wind chill is equal to (1.6*float(temperature)-55)
Helpful Stuff :1.Example of Sqrt Function
2.Reference manual of Ada(for Information on Sqrt)
Part 3
Optional
Problem: To write an ADA program that determines th winner in a game of "rock,paper,scissors".In this game ,two players choose
either rock,paper,scissor.Whether a player wins or looses depends upon the choice of the player and the choice of the
opponents choice.
How does a player win:
Rock breaks scissors :rock wins
Paper covers rock :paper wins
Scissors cuts paper :scissor wins
If both select same then it is a tie
Task :The program should prompt the users to enter choices in the following format.
"Please enter the choices made by the two players "
scissor rock
It should then determine the winner and then print the winner.
"The second players choice of rock beat scissor"
Use : 1.enumneration type
2.IF Then else statement
Helpful Stuff : Example on Enumneration types
Ryan Stansifer <ryan@cs.fit.edu>
Last modified: Tue Jan 26 15:19:11 EST 1999