comp.lang.ada
 help / color / mirror / Atom feed
* Re: Using ADA to write a Grade Program (ARRAYS)
  1998-04-19  0:00 Using ADA to write a Grade Program (ARRAYS) Sam
@ 1998-04-19  0:00 ` Robert Dewar
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1998-04-19  0:00 UTC (permalink / raw)



Sam posted some tentative Ada-like code ...


Sam, this is very approximate Ada code. You may be able to get enough
comments to beat it into shape, but I think you will find in the long run that
it is far more effective, and less frustrating, to really learn the precise
details you need to write accurate code from the start. At least that is my
experience with people learning to program.

I see a number of students who work this way -- write very approximate code
and then ask for help and advice to correct it. It works for the simple 
programs given out as assignments early on, or at least works well enough,
but in the long run, it is a bad idea, and when the assignments get more
complex, you run into real problems. You need to learn *at this stage* how
to write *for yourself* (without outside help) precise code that does exactly
what you want. 

Yes, this is hard work, but it is hard work that will pay off later.

I suggest taking the time and effort to work through one of the on line
tutorials that are accessible from the net (look at www.adahome.com to get
references). If you work a tutorial, and really understand each point, then
you will be able to come back to a trivial assignment like the one you are
working on, and you will be surprised to agree that it is indeed trivial!

I post this rather than send it as email, because I know a lot of students
read this newsgroup, and this is generally useful advice.

P.S. the code you posted contains at least 15 errors, most of them
pretty serious, and in several places the code is so garbled that it is
hard to even guess what you had in mind.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Using ADA to write a Grade Program (ARRAYS)
@ 1998-04-19  0:00 Sam
  1998-04-19  0:00 ` Robert Dewar
  0 siblings, 1 reply; 2+ messages in thread
From: Sam @ 1998-04-19  0:00 UTC (permalink / raw)



I am very pleased with the response, I guess I need to include further
details:

I need to write an ADA program that reads grade information
(names/grades) into two ARRAYS, one for names the other for grades.
Then compute the average, print out a file that shows the student's
name, his grade and the word Satisfacory or Unsatisfactory, if the grade
is within 10 points of average.  Here is the code I have so far:

Type float ARRAY is ARRAY (1..20) of Floats
  A: Float
   i : Integer := 0
   Avg, Sum, Below : Integer := 0
Begin
    While Not Endo Of File Loop
      Ada.Integer_Text_IO.Get (a(i));
      Sum := Sum + a(i);
      i := i + 1;
      End Loop

Avg := Sum/ "this I am not sure about?"

    For i in i..(i-1) Loop
    If a(i) < avg THEN
    Below := Below = 1;
    ELSIF a(i) > avg THEN
    Above := Above + 1;
    Else
    Same := Same + 1;
    End If
   End Loop............this is where my problem happens, how do I attach
a string to this, and how do I produce the end result......I am kinda
stuck, thanks to anyone who assists me.

Sam





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-04-19  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-19  0:00 Using ADA to write a Grade Program (ARRAYS) Sam
1998-04-19  0:00 ` Robert Dewar

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