Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 3rd, 2006, 07:33 PM
javalearner7 javalearner7 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 87 javalearner7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 8 m 55 sec
Reputation Power: 3
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;

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Ada Help - Also Posted on Archive Page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway