syuan (syuan) wrote in programmerguild,
syuan
syuan
programmerguild

  • Mood:

Help!!!

Hi, I'm new to the community. I study Graphics Design (this is my first year) but we started with Computer Science in general. I have no idea about programming and I don't get pascal at all... Can anyone help me with writing a program?

I'm supposed to create a program using Delphi7 (=> console type). There's a .txt file with a list of 4 students, the number of their grades and the list of the grades. The program should count the average of the grades for each student and then sort the names by the average, lowest to highest.


Kowalski Andrzej
4
3 3.5 4 3.5

Nowak Siergiej
5
5 3 4.5 4 2.5

Elfryda Ciupaga
4
4 4 3 4.5

Gertruda Cebula
3
5 4 3.5


I tried to do it myself but I'm a poor programmer. Here's what I came up, but most of it is probably wrong.



program Project2;

{$APPTYPE CONSOLE}

uses
SysUtils;

const max = 20;

type

student = record end;
ave = real;
studentlist = array [1..max] of student;

var
f: text;
no, i : integer;
sum : real;
name : string;
u : studentlist;
N : 4;

begin
assign(f, 'data.txt');
reset(f);

for 1..N do
u[i];

readln (f; u) name;
readln(f, no);
sum : 0;

for i:= 1 to no do

begin
read(f, grade);
sum:= sum + grade;
end;

u.ave := sum/no;
{ TODO -oUser -cConsole Main : Insert code here }
end.


If somebody can help me I'd be really grateful. I promise to study more on the pascal in the future.
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 0 comments