Jump to content

help me with my homework


piterdevries

Recommended Posts

Got something like this...

but this is borland pascal.. ;)


program Numbers;
uses crt;
var a, b, c: integer;
begin
  clrscr;
  write('Give 3 numbers: ');
  readln(a, b,c);
  if a > b then
      begin
        b := a + b;
        a := b - a;
        b := b - a
      end;
  if a > c then
      begin
        c := a + c;
        a := c - a;
        c := c - a
      end;
  if b > c  then
      begin
        c := c + b;
        b := c - b;
        c := c - b
      end;
  writeln(a:2, b:2, c:2);
  readln
end.

or more like this:


{
}
PROGRAM study2;
USES crt;

const max = 10;
var number2: real;
{TYPES}
type tString10 = string[10];
    tDate    = record
                    year  :integer;
                    month :1..12;
                    day  :1..31
                end;
    tStudent  = record
                    studentnumber :tString10;
                    studentname  :tString10;
                    education    :tString10
                end;
    tModule  = record
                    modulenumber  :tString10;
                    modulename    :tString10;
                    semesternumber    :tString10
                end;
    ttest    = record
                    modulenumber  :tString10;
                    studentnumber :tString10;
                    date        :tdate;
                    result        :real
                end;
    tTabelstudent = array[1..max] of tStudent;
    tTabelmodule  = array[1..max] of tModule;
    tTabeltest  = array[1..max] of ttest;

{PROCEDURES}
procedure read_in_student(var input: text; var tabel: tTabelstudent; var length: integer);
begin
  clrscr;
  reset(input);  length := 0;
  while not eof(input) do
      begin
        length := length + 1;
        read(input, tabel[length].studentnumber);
        read(input, tabel[length].studentname);
        read(input, tabel[length].education);
        readln(input)
      end
end;

procedure write_student(var tabel: tTabelstudent; length: integer);
var i :integer;
begin
  for i := 1 to length do
      begin
        write(tabel[i].studentnumber);
        write(tabel[i].studentname);
        write(tabel[i].education);
        writeln
      end;
  writeln
end;


procedure read_in_module(var input: text; var tabel: tTabelmodule; var length: integer);
begin
  reset(input);
  length := 0;
  while not eof(input) do
      begin
        length := length + 1;
        read(input, tabel[length].modulenumber);
        read(input, tabel[length].modulename);
        read(input, tabel[length].semesternumber);
        readln(input)
      end
end;

procedure write_module(var tabel: tTabelmodule; length: integer);
var i :integer;
begin
  for i := 1 to length do
      begin
        write(tabel[i].modulenumber);
        write(tabel[i].modulename);
        write(tabel[i].semesternumber);
        writeln
      end;
  writeln
end;

procedure read_in_test(var input: text; var tabel: tTabeltest; var length: integer);
begin
  reset(input);
  length := 0;
  while not eof(input) do
      begin
        length := length + 1;
        read(input, tabel[length].modulenumber);
        read(input, tabel[length].studentnumber);
        read(input, tabel[length].date.year);
        read(input, tabel[length].date.month);
        read(input, tabel[length].date.day);
        read(input, tabel[length].result);
        readln(input)
      end
end;

procedure write_test(var tabel: tTabeltest; length: integer);
var i :integer;
begin
  for i := 1 to length do
      begin
        write(tabel[i].modulenumber);
        write(tabel[i].studentnumber);
        write(tabel[i].date.year:5);
        write(tabel[i].date.month:3);
        write(tabel[i].date.day:3);
        write(tabel[i].result:6:1);
        writeln
      end;
  writeln
end;

procedure show_result(nameinput: tString10; modulenameinput: tString10;
length1, length2, length3: integer; var tabel1: tTabelstudent; var tabel2: tTabelmodule; var tabel3: tTabeltest);

var i, ii: integer;
    studentnametemp, modulenametemp, modulenumbertemp, studentnumbertemp: string[10];

begin
  for i := 1 to length1 do
      if nameinput = tabel1[i].studentname then
        begin
        studentnametemp := tabel1[i].studentname;
        studentnumbertemp := tabel1[i].studentnumber
        end;

  for ii := 1 to length2 do
      if modulenameinput = tabel2[i].modulename then
          begin
          modulenametemp := tabel2[i].modulename;
          modulenumbertemp := tabel2[i].modulenumber;
          for ii := 1 to length3 do
            if (studentnumbertemp = tabel3[ii].studentnumber) and (modulenumbertemp = tabel3[ii].modulenumber) then
            writeln(studentnumbertemp, modulenumbertemp, tabel3[ii].result)
          end;
      modulenumbertemp := 'false';
end;

Procedure write_result(nameinput: tString10; modulenameinput: tString10; studentnametemp: tString10;
modulenumbertemp: tString10;
length1, length2, length3: integer; var tabel1: tTabelstudent; var tabel2: tTabelmodule; var tabel3: tTabeltest);
var ii: integer;
  begin
      write(studentnametemp);
      write(modulenumbertemp);
      write(tabel3.result)
  end
end;

{MAINPROGRAMMA}
VAR inputtext1, inputtext2, inputtext3 :text;
    ylength1, ylength2, ylength3 :integer;
    tabelstudent : tTabelstudent;
    tabelmodule  : tTabelmodule;
    tabeltest  : tTabeltest;
    tabel3        : tTabeltest;
    nameinput, modulenameinput, studentnumbertemp, modulenumbertemp : String[10];
    result : real;
BEGIN
  clrscr;
  assign(inputtext1, 'student.txt');
  assign(inputtext2, 'module.txt');
  assign(inputtext3, 'test.txt');
  number2 := 0;
  read_in_student(inputtext1, tabelstudent, ylength1);
  write_student(tabelstudent, ylength1);
  read_in_module(inputtext2, Tabelmodule, ylength2);
  write_module(tabelmodule, ylength2);
  read_in_test(inputtext3, tabeltest, ylength3);
  write_test(tabeltest, ylength3);
  writeln('Studentname: ');
  readln(nameinput);
  writeln('Modulename: ');
  readln(modulenameinput);
  show_result(nameinput, modulenameinput, ylength1, ylength2,
              ylength3, Tabelstudent, Tabelmodule, Tabeltest);
  writeln;
readln
END.

ah yeah, this program reads from some files (student.txt, module.txt and test.txt) and you can request some info according test results and such things..

gryphon might know this one ;)

Link to comment
Share on other sites

Why don't people ever ask for help with economics instead?

Face it, it's dull... :P

Doing CS myself, and I must say this is one weird assignment. We usually were warned not to program such repetitions of code, but instead call the same code multiple times.

Better make copies of one working program, and change a few things in each program, than finding them all on the internet.

(On a side note, iteration sucks once you've learned of the powers of recursion ;))

Link to comment
Share on other sites

Face it, it's dull... :P

One of my economics professors in college told us about the time he was forced to read Milton Friedman's "A Monetary History of the United States" back when he was a student. It's over 800 pages and discusses the evolution of the money supply (yes, the money supply) in the United States from 1867 to 1960. He described it as causing "such an intense feeling of boredom that your synapses want to commit ritual suicide".

So, yeah, econ can be a little dull at times, but I like it. :P

Link to comment
Share on other sites

Econ can be boring and interesting. Some econ books put me to sleep, others I don't mind reading. My prof is going to Asia (maybe sri lanka) for some economic development conference or something, so no classes for two weeks in it :D

see economics classes can also have some advantages.. :D

Link to comment
Share on other sites

I absolutely loooove money supply!! I've just listened to some Friedman video a month ago, about money supplies and more... the most interesting was Friedman's rhetoric given how uninstructive he was on supplies but oh well ;D

[hide]/me dreams of supplies... money supplies, oil supplies... SPICE supplies. Who controls spice...[/hide]

very interesting indeed ;)

Link to comment
Share on other sites

  • 1 month later...

here i am again,,, this time that prof of mine gave us a project that would leave us exempted in the final exams if we ever manage to make it...

he said that this program must display a word, for example Dune.

Then a colored dash ( - ) or any other symbol must march around that word (just like Microsoft Word's marching red ants effect)..

help me guys. just give me an idea on how to do it.... thanks a lot

Link to comment
Share on other sites

  • 2 weeks later...

Helping fellow humans, alchi.

Boy asks sister "Will you do my homework for me ?"

Sister says "No, it wouldnt be right"

Boy replies "Yes, you probably wouldnt get it right"

Or something like that. God I cant tell a joke to save my life.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...