please enjoy this file.......
http://www.4shared.com/file/3gy7Hfbq/tugas.html
I hope, it will help you full.......
Showing posts with label programing. Show all posts
Showing posts with label programing. Show all posts
4/13/11
3/25/11
Price List Part 2 (final reallese)
This program is new version of Price List program in pascal code. In the past program the price list just show name and price of the Item. With color spesification you can input same name and find it corectly be entering the name and the color of the item.
This is the syntax.
This is the syntax.
uses wincrt;
type data1=array [1..20] of string;
type data2=array [1..20] of real;
var
position,n,i,x:byte;
name,color:data1;
price:data2;
found:boolean;
find1,find2:string;
again:char;
find3,average,min,max,total:real;
begin
repeat;
begin
inc(n);
writeln('Input the items name ',n:2,' for stop type xxx==>');
readln(name[n]);
writeln('Input the items color ==>');
readln(color[n]);
writeln('Input the items price ==>');
readln(price[n]);
total:=total+price[n];
end
until(name[n]='xxx');
dec(n);
clrscr;
writeln('PRICE LIST BLANTIK ONLINE');
writeln('No Name Color Price');
writeln('--------------------------------------');
for i:=1 to n do
writeln(i:3,'|',name[i]:13,'|',color[i]:10,' $',price[i]:10:2);
writeln('--------------------------------------');
{Min, max, average}
average:=total/n;
min:=price[1];
max:=price[1];
find1:=name[1];
writeln('The average of the items price is ==> $ ',average:10:2);
for i:=2 to n do
begin
if min>price[i] then begin min:=price[i];find1:=name[i];end;
end;
writeln('The cheapest item is ',find1,' with price ==> $ ',min:10:2);
for i:=2 to n do
begin
if max<price[i] then begin max:=price[i];find1:=name[i];end;
end;
writeln('The most expensive item is ',find1,' with price ==> $ ',max:10:2);
{searching}
again:='y';
while again='y'do
begin
writeln;
write('Which items price are you lokking for? ');readln(find1);
write('Which color do You want? ');readln(find2);
found:=false;
for i:=1 to n do
begin
if name[i]=find1 then
begin
if color[i]=find2 then
begin
found:=true;position:=i;find3:=price[i];
end;
begin
found:=true;position:=i;find3:=price[i];
end;
end;
end;
writeln;
if found then writeln('The price of the ',find2,' ',find1,' is $ ',find3:10:2,' as data number ',position,'.')
else writeln('sorry there is not ',find2,' ',find1,' in the array.');
writeln;
write('Do you want to do it again?<y,n> ');readln(again);
end;
end.
3/22/11
pricelist program in pascal syntax (array, while do, for to do, if then else)
Pricelist is table may contains data of items name and price. From this pricelist you may get data about average of the price, the cheapest and the most expensive items price. The user can search the specific item price with only type the item name.
This is the syntax:
uses wincrt;
type data1=array [1..20] of string;
type data2=array [1..20] of real;
var
position,n,i:byte;
name:data1;
price:data2;
found:boolean;
find1:string;
again:char;
find2,average,min,max,total:real;
begin
repeat;
begin
inc(n);
writeln('Input the items name',n,'for stop type xxx==>');
readln(name[n]);
writeln('Input the items price ==>');
readln(price[n]);
total:=total+price[n];
end
until(name[n]='xxx');
dec(n);
clrscr;
writeln('PRICE LIST BLANTIK ONLINE');
writeln('No Name Price');
writeln('--------------------------------');
for i:=1 to n do
writeln(i:3,'|',name[i]:13,'| $',price[i]:10:2);
writeln('--------------------------------');
{Min, max, average}
average:=total/n;
min:=price[1];
max:=price[1];
find1:=name[1];
writeln('The average of the items price is ==> $ ',average:10:2);
for i:=2 to n do
begin
if min>price[i] then min:=price[i];find1:=name[i];
end;
writeln('The cheapest item is ',find1,' with price ==> $ ',min:10:2);
for i:=2 to n do
begin
if max<price[i] then max:=price[i];find1:=name[i];
end;
writeln('The most expensive item is ',find1,' with price ==> $ ',max:10:2);
{searching}
again:='y';
while again='y'do
begin
writeln;
write('Which items price are you lokking for?');readln(find1);
found:=false;
for i:=1 to n do
begin
if name[i]=find1 then found:=true;position:=i;find2:=price[i];
end;
writeln;
if found then writeln('The price of ',find1,' is $ ',find2:10:2,' as data number ',position)
else writeln('sorry there is not ',find1,' in the array');
writeln;
write('Do you want to do it again?<y,n>');readln(again);
end;
end.
This is the syntax:
uses wincrt;
type data1=array [1..20] of string;
type data2=array [1..20] of real;
var
position,n,i:byte;
name:data1;
price:data2;
found:boolean;
find1:string;
again:char;
find2,average,min,max,total:real;
begin
repeat;
begin
inc(n);
writeln('Input the items name',n,'for stop type xxx==>');
readln(name[n]);
writeln('Input the items price ==>');
readln(price[n]);
total:=total+price[n];
end
until(name[n]='xxx');
dec(n);
clrscr;
writeln('PRICE LIST BLANTIK ONLINE');
writeln('No Name Price');
writeln('--------------------------------');
for i:=1 to n do
writeln(i:3,'|',name[i]:13,'| $',price[i]:10:2);
writeln('--------------------------------');
{Min, max, average}
average:=total/n;
min:=price[1];
max:=price[1];
find1:=name[1];
writeln('The average of the items price is ==> $ ',average:10:2);
for i:=2 to n do
begin
if min>price[i] then min:=price[i];find1:=name[i];
end;
writeln('The cheapest item is ',find1,' with price ==> $ ',min:10:2);
for i:=2 to n do
begin
if max<price[i] then max:=price[i];find1:=name[i];
end;
writeln('The most expensive item is ',find1,' with price ==> $ ',max:10:2);
{searching}
again:='y';
while again='y'do
begin
writeln;
write('Which items price are you lokking for?');readln(find1);
found:=false;
for i:=1 to n do
begin
if name[i]=find1 then found:=true;position:=i;find2:=price[i];
end;
writeln;
if found then writeln('The price of ',find1,' is $ ',find2:10:2,' as data number ',position)
else writeln('sorry there is not ',find1,' in the array');
writeln;
write('Do you want to do it again?<y,n>');readln(again);
end;
end.
3/20/11
Pascal programs for primes
This is pascal script to find primes from (a) to (b).
uses wincrt;
var
a,b,x,y : integer;
hasil1 : longint;
again,primes: boolean;
begin
again:=true;
repeat
var
a,b,x,y : integer;
hasil1 : longint;
again,primes: boolean;
begin
again:=true;
repeat
begin
write('Count primes from');read(a);write('to');readln(b);
for x:=a to b do
begin
primes :=true;
for y:=2 to x-1 do
begin
if (x mod y)=0 then
begin
primes:=false;
end;
end;
if primes then write (x:5);
end;
end;
end;write('Count primes from');read(a);write('to');readln(b);
for x:=a to b do
begin
primes :=true;
for y:=2 to x-1 do
begin
if (x mod y)=0 then
begin
primes:=false;
end;
end;
if primes then write (x:5);
end;
end;
readln;
until not again;
end.
Subscribe to:
Posts (Atom)