Hi i have an assignment to write a Shopping List program in which there can be any number of products entered along with the price. Im not really doing to well with it an would apprecite any help.

Heres my prgram so far

program ShoppingList (input,output);
 
var numb:integer; 
      prod:char; 
      price:real;
 
begin
     Repeat
     write('Please enter the number of products you wish to buy');
     read(numb);
     until numb < 100;
     readln;
     for numb:= 1 to (numb) do
   begin
      write('Please Enter product');
      read(prod);
      readln;
      write('Please Enter the Price');
      read(price);
     readln;
   end;
end.

This works but does not display the text in a good format and i am not able to add up the total cost of the items which would help. I was thinking of trying to display it like this

Shopping List
 
Product  Price
 
ham      £0.9
 
etc

By using write('Shopping List');
write;
write('Product Price');
write(prod, price);

howvere i know this wont work and was jsut wondering if anyone has any ideas which could help me find the solution. Any help would be appreciated.

thanks in advance.

Recommended Answers

All 2 Replies

Hi,

1.Try this :
writeln('Shopping List');
writeln('Product Price');
writeln(prod+' '+price);

2.Instead of :
read([something]);
readln;

use

readln([something]);

3. You need two arrays to record the entered values for them not to overwrite the previous values.

Loren Soth

Thanks for the help ill look into arrays. =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.