|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Ada Help - Also Posted on Archive Page
** I also posted the same information on the Archive Page**
The assignment was to create a program that will calculate Easter Sunday for a given year. I wrote this program in C++ for an earlier assignment and now the professor is asking us to write it in a new language and his choice was Ada. I was reading a couple books on Ada but not too sure how the procedures work. You might find in my code some C++ by mistake. Can someone could please guide me in the right direction? Thank you very much in advance! Mike R. with Ada.Text_IO; use Ada.Text_IO; package body hmwk2 is function int_to_string(n: Integer) return String is begin if n < 0 then return "-" & int_to_string(abs(n)); elsif n < 10 then return "" & Character'Val(n + Character'Pos('0')); else return int_to_string(n/10) & int_to_string(n rem 10); end if; end; function easter_date(y: Integer) return String is Golden, Century, Correc1, Correc2, Sunday, Epact, Fmoon : Integer; begin Golden := (y rem 19) +1; Century := (y/100)+1; Correc1 := ((3 * Century) / 4) - 12; Correc2 := (((8 * Century) + 5) / 25) - 5; Sunday := ((5 * Y) / 4) - Correc1 - 10; Epact := (11 * Golden +20 + Correc2 - Correc1) rem 30; if Epact = 25 and then Golden > 11 then Epact := Epact + 1; end if; if Epact = 24 then Epact := Epact + 1; end if; Fmoon := 44 - Epact; if Fmoon < 1 then Fmoon := Fmoon + 30; end if; Fmoon := Fmoon + 7 - ((Sunday + Fmoon) rem 7); if Fmoon > 31 then Fmoon := Fmoon - 31; return Fmoon; Put (" April"); New_Line; else return Fmoon; Put(" March"); Put_Line; end if; end; end hmwk2; |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Ada Help - Also Posted on Archive Page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|