Help with a simple program?

thanks for your help i got the program to work but i will only display the final cost discount and total cost before discount i will try to make it display all items entered after my presentation.


  • You can use repeat..(write(..);read(..);)..until UnitP=0; or any other number. Or readln(n),n-number of your items and then for i:=1 to n do
    In 2 case you should write array_name:array of integer; in var without [0..5] next write array_name:= new integer[n]; But in 1 case write just [1..100(or 1000)]
    To write down the info create .txt document then
    rewrite(file_name, what_you_want_to_write);
    Ask if you didn't get anything.

  • sorry for the long reply i don't quite understand the advice you gave could you simplify it a bit i would help tremendously.
  • ok so i used the readln(n)u suggested for number of items which which will then go into the into the index as... for index:=1 to n do her is how i how wrote the vars

    [color=Blue]ItemN:array of integer;
    UnitP:array of integer;
    Quantity:array of integer;
    Writeln('Enter amount of goods');
    for index := 1 to n do
    Writeln('Enter Item name');
    Readln(ItemN [index]);

    this code compiles but as soon as i enter the [u]item name[/u] the program stops what am i doing wrong ? :(
  • 1. you can write [b]ItemN, UnitP, Quantity :array of integer;[/b]
    2. if you wanna enter the name the array should be [b]string[/b], not [b]integer[/b]
    3. after that all don't forget to write [b]end;[/b] and [b]end.[/b]
    4. program need to know the number of items in the array, you should write [b]ItemN := new string[n + 1];[/b], n+1 because it starts from 0
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!