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 begin..(write(..);read(..);)..end; 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 assign(file_name,the_way_to_the_file); rewrite(file_name, what_you_want_to_write); close(file_name); Ask if you didn't get anything.
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; UnitT,totalprice,discount:real; index,n:integer; Begin clrscr; Writeln('Enter amount of goods'); readln(n); for index := 1 to n do begin[/color] 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
Comments
begin..(write(..);read(..);)..end;
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
assign(file_name,the_way_to_the_file);
rewrite(file_name, what_you_want_to_write);
close(file_name);
Ask if you didn't get anything.
[color=Blue]ItemN:array of integer;
UnitP:array of integer;
Quantity:array of integer;
UnitT,totalprice,discount:real;
index,n:integer;
Begin
clrscr;
Writeln('Enter amount of goods');
readln(n);
for index := 1 to n do
begin[/color]
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 ?
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