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;
TempAverage     : integer;

TempAverage := Round(Average);
Case TempAverage of
End; {Case}

{------------------------------------------------}
Procedure GetInput;
Var NoStudents, Score                 : integer;
Average                           : real;

{------------------------------------------------}
Procedure ShowOutput;
Var KeyPress                           : char;
WhichStudent                       : integer;

{------------------------------------------------}
Procedure Continue;

Begin {procedure Continue}
Clrscr;

End;  {procedure Continue}

Begin {procedure ShowOutput}
Clrscr;

{-- 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 --}
Clrscr;GotoXY(23,9);
WriteLn('Which student you want to display?');GotoXY(23,10);
GotoXY(21,11);WriteLn('Here is the information for Student #',
WhichStudent);
GotoXY(15,13);
WriteLn('Student     Number     Score     Average
Letter');GotoXY(15,14);
WriteLn('???????????????????????????????????????????????????');GotoXY(15,16
);
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];
WriteLn(Average:4:1);

End

Else    {-- Show all averages here --}

End;  {procedure ShowOutput}

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

GotoXY(23,12);
WriteLn('How many students you want to enter?');
GotoXY(23,14);

{--- e r r o r  t r a p ---}
If NoStudents > MaxStudents Then
Begin
Clrscr;GotoXY(21,12);
WriteLn('You entered more students than allowed!');
NoStudents := 0;     {reset the number of students}
GotoXY(29,14);
GetInput;     { - restart GetInput procedure - }
End;

For Count := 1 to NoStudents Do
Begin
Clrscr;GotoXY(26,12);
WriteLn('How many tests for student #',Count,'?');
GotoXY(26,14);

{--- e r r o r  t r a p ---}
If Scores[Count,1] > MaxTests Then
Begin
Clrscr;GotoXY(21,12);
WriteLn('You entered more tests than allowed!');
NoStudents := 0;          {reset the number of students}
Scores[Count,1] := 0;     {reset the number of tests}
GotoXY(29,14);
GetInput;     { - restart GetInput procedure - }
End;

Scores[Count,2] := 0;

For Count2 := 1 to Scores[Count,1] Do
Begin
Clrscr;GotoXY(19,12);
WriteLn('Enter the score for test #',Count2,' for Student #',Count);
GotoXY(19,14);
Scores[Count,2] := Scores[Count,2] + Score
End;

End;

ShowOutput;

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}

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

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

Quote

>         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.

--Walt.

--
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
doctors.

-----------== Posted via Deja News, The Discussion Network ==----------

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

Quote
>     Clrscr;GotoXY(23,9);
>     WriteLn('Which student you want to display?');GotoXY(23,10);
>     GotoXY(21,11);WriteLn('Here is the information for Student #',
>WhichStudent);
>     GotoXY(15,13);
>     WriteLn('Student     Number     Score     Average
>Letter');GotoXY(15,14);
>     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.

Osmo