From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a5193bb70b7caf8 X-Google-Attributes: gid103376,public From: Alan Brain Subject: Re: Help with Ada 95 Date: 1997/10/02 Message-ID: <34330F64.178B@cs.adfa.oz.au>#1/1 X-Deja-AN: 277233028 References: <3431E010.4DB9@earthlink.net> Organization: ADFA News Service Newsgroups: comp.lang.ada Date: 1997-10-02T00:00:00+00:00 List-Id: 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