Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Help with a simple program? Posted by Stpdougie on 8 Nov 2011 at 5:53 PM
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.

Report
Re: Help with a simple program? Posted by Dmitry_Zorin on 9 Nov 2011 at 6:17 AM
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.


Report
Re: Help with a simple program? Posted by Stpdougie on 14 Nov 2011 at 3:54 PM
sorry for the long reply i don't quite understand the advice you gave could you simplify it a bit i would help tremendously.
Report
Re: Help with a simple program? Posted by Stpdougie on 14 Nov 2011 at 5:33 PM
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

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

Writeln('Enter Item name');
Readln(ItemN [index]);

this code compiles but as soon as i enter the item name the program stops what am i doing wrong ? :(
Report
Re: Help with a simple program? Posted by Dmitry_Zorin on 16 Nov 2011 at 7:02 AM
1. you can write ItemN, UnitP, Quantity :array of integer;
2. if you wanna enter the name the array should be string, not integer
3. after that all don't forget to write end; and end.
4. program need to know the number of items in the array, you should write ItemN := new string[n + 1];, n+1 because it starts from 0



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.