comp.lang.ada
 help / color / mirror / Atom feed
From: Alan Brain <abrain@cs.adfa.oz.au>
Subject: Re: Help with Ada 95
Date: 1997/10/02
Date: 1997-10-02T00:00:00+00:00	[thread overview]
Message-ID: <34330F64.178B@cs.adfa.oz.au> (raw)
In-Reply-To: 3431E010.4DB9@earthlink.net


masi@earthlink.net wrote:
> 
> Hi, I'm taking my first Ada 95 class at my college and am having a
> problem  with it.  I have small projects due soon, and need some kind of
> instructions.  Could anyone help me?

Try the lovelace tutorial at http://www.adahome.com

> Here is two programs I'm supposed to make:

OK, without doing your work for you, here are some questions:

> 
> 1) function Root (A, B, C : in Float) return Float;
> --
> -- This returns the root of the equation
> --      Ax + B = C
> -- if one exists, otherwise it raises a Constraint_Error.


OK, See if I understand the question:
let's look at the equation first. Some really elementary
algebraic manipulation:

Ax+B = C becomes (by subtracting C from both sides)
Ax = C-B, and this becomes (by dividing both sides by A)
x = (C-B)/A

Now this will always exist, except under WHAT conditions?



> 2) function DigitSum ( N : Positive ) return Positive;
> --
> -- This returns the sum of the digits of the number N.
> --
> -- Example: DigitSum (1532) = 11 (since 1+5+3+2 = 11).

OK, the input is an integer (Positive actually). You need the
sum of the digits.
There are several ways of doing this.

Look up mod. I assume you're familiar with modular arithmetic,
such as in telling time: 11 o'clock + 2 hours later = 1 o'clock,
or 13 mod 12.

If you've covered STRINGS, also look up 'IMAGE.

Which would be the best to use?

-- 
Not the Australian Dairy Farmers Association,
   the Australian Defence Force Academy.
aebrain@dynamite.com.au abrain@cs.adfa.oz.au




  reply	other threads:[~1997-10-02  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-30  0:00 Help with Ada 95 masi
1997-10-02  0:00 ` Alan Brain [this message]
1997-10-02  0:00 ` Richard A. O'Keefe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox