Board index » delphi » The whole program so far... suggestions please

The whole program so far... suggestions please

        This is my whole program that I wrote so far.

{Name:.......Daniel Fruge                                              }
{Class:......CSC1248 Pascal                                            }
{Instructor:.M. AxelRod                                                }
{Program:....Final                                                     }
{Purpose:....This program accepts a series of test scores from the user}
{............for each of a number of students declared by the user.    }

Program Final(input, output);
 uses Crt;

 Const MaxStudents = 24;        {maximum students allowed}
       MaxTests    = 12;        {maximum tests for a student}

 Type Students = 1 .. MaxStudents;
      Tests    = 1 .. MaxTests;

      TestArray = Array[1..2] of Integer;
      TestTable = Array[Students] of TestArray;

 var  Scores               : TestTable;
      Count, Count2        : Integer;

Function LetterGrade (Average : Real) : Char;
 Var LetterGrade     : char;
     TempAverage     : integer;

 Begin {Function LetterGrade}

  TempAverage := Round(Average);
   Case TempAverage of
    100..91: LetterGrade := 'A';
    90..81:  LetterGrade := 'B';
    80..71:  LetterGrade := 'C';
    70..61:  LetterGrade := 'D';
    60..0:   LetterGrade := 'F';
   End; {Case}

 End;  {Function LetterGrade}

Procedure GetInput;
 Var NoStudents, Score                 : integer;
     Average                           : real;

Procedure ShowOutput;
 Var KeyPress                           : char;
     WhichStudent                       : integer;

Procedure Continue;

 Begin {procedure Continue}

 End;  {procedure Continue}

 Begin {procedure ShowOutput}

  {-- Make a loop here --}
  WriteLn('Press "A" to display ALL the averages or');
  WriteLn('any other key to go to the PrintOne section.');
  KeyPress := UpCase(KeyPress);
   If KeyPress <> 'A' Then
    Begin  {-- Print One Section --}
     WriteLn('Which student you want to display?');GotoXY(23,10);
     GotoXY(21,11);WriteLn('Here is the information for Student #',
     WriteLn('Student     Number     Score     Average    
     WriteLn('Number     of Grades   Total      Score      
     WriteLn('   ',WhichStudent);GotoXY(29,16);
     WriteLn(Scores[WhichStudent,1]);GotoXY(39,16); { -- Number of Tests -- }
     WriteLn(Scores[WhichStudent,2]);GotoXY(50,16); { -- Test Totals --}
     Average := Scores[WhichStudent,2] / Scores[WhichStudent,1];
{      LetterGrade(Average);



   Else    {-- Show all averages here --}

 End;  {procedure ShowOutput}

 Begin {procedure GetInput}
 TextColor(White); TextBackground(Black); {Reset colors}

  WriteLn('How many students you want to enter?');
  ReadLn(NoStudents);                  {Read in how many students}

  {--- e r r o r  t r a p ---}
  If NoStudents > MaxStudents Then
    WriteLn('You entered more students than allowed!');
    NoStudents := 0;     {reset the number of students}
    WriteLn('Press ENTER to continue');ReadLn;
     GetInput;     { - restart GetInput procedure - }

  For Count := 1 to NoStudents Do
   WriteLn('How many tests for student #',Count,'?');

   {--- e r r o r  t r a p ---}
   If Scores[Count,1] > MaxTests Then
     WriteLn('You entered more tests than allowed!');
     NoStudents := 0;          {reset the number of students}
     Scores[Count,1] := 0;     {reset the number of tests}
     WriteLn('Press ENTER to continue');ReadLn;
      GetInput;     { - restart GetInput procedure - }

   Scores[Count,2] := 0;

    For Count2 := 1 to Scores[Count,1] Do
     WriteLn('Enter the score for test #',Count2,' for Student #',Count);
     Scores[Count,2] := Scores[Count,2] + Score



 End;  {procedure GetInput}

Procedure ShowInfo;
 var xPos, yPos   : integer;

 Begin {procedure ShowInfo}

 TextColor(White); TextBackground(Black); {Reset colors}
 Clrscr; {clear the screen}
 xPos :=21; yPos :=5; {set the begining X and Y coordinates}
 TextColor(Yellow); TextBackground(Blue);
 GotoXY(xPos, yPos);   WriteLn('??????????????????????????????????????????');
 GotoXY(xPos, yPos+1); WriteLn('3 Welcome to my Average Grade Program     3');
 GotoXY(xPos, yPos+2); WriteLn('??????????????????????????d?fruge?????????');
 GotoXY(xPos, yPos+3); WriteLn('3   This program will ask you how many    3');
 GotoXY(xPos, yPos+4); WriteLn('3  students & grades you want to input.   3');
 GotoXY(xPos, yPos+5); WriteLn('3  The maximum number of students is 24.  3');
 GotoXY(xPos, yPos+6); WriteLn('3   The maximum number of scores is 12.   3');
 GotoXY(xPos, yPos+7); WriteLn('3 The program will calculate the average  3');
 GotoXY(xPos, yPos+8); WriteLn('3  for each student and class and assign  3');
 GotoXY(xPos, yPos+9); WriteLn('3 a letter grade.                         3');
 GotoXY(xPos, yPos+10);WriteLn('3  The program will give display options  3');
 GotoXY(xPos, yPos+11);WriteLn('3 for each student, a particular student, 3');
 GotoXY(xPos, yPos+12);WriteLn('3 and the whole class.                    3');
 GotoXY(xPos, yPos+13);WriteLn('?????????????????????           ??');
 GotoXY(xPos, yPos+14);WriteLn('?????????????????????????????????????????');
 Delay(8000); GotoXY(xPos+25, yPos+13); WriteLn('press ENTER'); ReadLn;

 End;  {procedure ShowInfo}

{----------------------------------Main Program--}
Begin {program Final}

 ShowInfo;                         {call the ShowInfo procedure}
 GetInput;                         {call the GetInput procedure}

End.  {program Final}



Re:The whole program so far... suggestions please

Leinad wrote:

>         This is my whole program that I wrote so far.
> ------------------

<code snipped>

First fix the errors that result in the compiler giving error
messages.  The compiler will flag them for you so I didn't
bother.  Then re-post for advice.  We really shouldn't do your
homework for you...

Al Moore


> --
> ....
> ...
> ..
> .
> ..l..........
> ...e........
> ....i......
> .....n....
> ......a..
> .......d.

Re:The whole program so far... suggestions please

First of all, what is your assignment?  By this, I mean, what specifically are
you supposed to accomplish?  What "problem" are you solving?

A good start.  The answers to the above questions should be helpful in
fleshing out this prog.


SPAM BLOCKING IN EFFECT: Only those in my address book can send me mail.
I've got an idea: let's sue all the lawyers and operate on all the

-----------== Posted via Deja News, The Discussion Network ==----------       Search, Read, Discuss, or Start Your Own    

Re:The whole program so far... suggestions please

In article <>,

Leinad <> wrote:
>     Clrscr;GotoXY(23,9);
>     WriteLn('Which student you want to display?');GotoXY(23,10);
>     ReadLn(WhichStudent);Clrscr;
>     GotoXY(21,11);WriteLn('Here is the information for Student #',
>     GotoXY(15,13);
>     WriteLn('Student     Number     Score     Average    
>     WriteLn('Number     of Grades   Total      Score      

Avoid putting more than one instruction per line. If you want more, put
those that logically belong together on same line. That is for example:

gotoxy(); writeln();

and not

writeln(); gotoxy();

as in the first the gotoxy specifies where the writeln outputs the
text. In the second there is no connection between them.


Other Threads