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.






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
  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;
readln;
until not again;
end.

Task 1

Salary
X (midpoint)
workers (f)
f*x
$250.00-$259.99
254.995
8
2039.96
$260.00-$269.99
264.995
10
2649.95
$270.00-$279.99
274.995
16
4399.92
$280.00-$289.99
284.995
14
3989.93
$290.00-$299.99
294.995
10
2949.95
$300.00-$309.99
304.995
5
1524.98
TOTAL


63
17554.69



Mean


It's mean that the average of the workers salary is $ 278.64.

Median



The position of median is in data number 32, it's mean the median in class of $270.00-$279.99 with frequency class is 16 and the bottom margin is $269.995. The total frequency class below is 18. The interval is $10.00.

 

So that is mean the middle data is $278.43.

Modus

Class with the highest frequency is $270.00-$279.99, with the frequency is 16.


So the highest appearance frequency data is $277.495.

UNIT 16


This activity practices Grammar Focus : Describing changes.
I got married.                   ==> I'm not single anymore.
I wear contacts now.       ==> I don't wear glasses anymore.
I've changed jobs.             ==> I'm a nurse now.
I've cut my hair.               ==> My hair is shorter now.
I move to a new place.     ==> I live alone now.

This activity practices Grammar Focus : Verb + invinitive.
Choose the correct words and phrases to complete the paragraph. There is one extra answer.

After I finish college, I'm going to travel for one month. I hope to visit Europe. Then I plan to get a job. I'd love to work in a bank.
The extra answer is like.

This activity practices Grammar Focus : Verb + infinitive.'
  • I plan to call some agencies next week.
  • I'd like to for a travel agency.
  • Well, I haven't found a job yet, but I hope to get one soon.
  • I'd love to travel, too – after I work and make some money!
  • What am I going to do after graduation?

The correct order is :
  • What am I going to do after graduation?
  • I'd love to travel, too – after I work and make some money!
  • Well, I haven't found a job yet, but I hope to get one soon.
  • I'd like to for a travel agency.
  • I plan to call some agencies next week.

UNIT 15


The activity practices Grammar Focus : Future with present continuous and be going to.
QUESTION                                                 ==> ANSWER
Ken, are you doing anything this weekend?          ==> No, I'm not.
Is Jack going to see a movie tonight?                    ==> No, he isn't.
Are you and your sister going to go to the party? ==> Yes, we are.
Is Linda going to go to the game?                         ==> Yes, she is.
Are your classmates going to study tonight?        ==> No, they aren't.

This activity practices Grammar Focus : Messages with tell and ask.
Complete the sentences with tell an ask.
  1. Could you ask Anita to call me tonight?
  2. Please tell Jeremy that we will meet at the restaurant.
  3. Would you tell Jean-Luc that there will be test tomorrow?
  4. Could you ask Maria to bring her camera to the party?
  5. Please ask Takashi to buy some snacks.
  6. Could you tell Eliza that I'll give her a ride tomorrow?

This activity practices useful telephone expressions.
Unscramble the sentences.
  1. Julie/may/speak/to/I
    May I speak to Julie?
  2. here/sorry,/isn't/Andy/but
    Sorry, but Andy isn't here.
  3. a/can/message/I/leave
    Can I leave a message?
  4. the/give/Sylvia/I'll/message
    I'll give Sylvia the message.
  5. take/I/can/message/a
    I can take a message.

UNIT 14


This activity practices Grammar Focus : Comparisons with adjectives.
Choose the correct words and phrases to complete the conversation. There is extra answer.
A: What is the tallest mountain in the world?
B: I'm not sure. I think it's K2.
A: Actually, Mt. Everest is taller than K2.
The extra answer is the most.

This activity practices Grammar Focus : Questions with how.
Complete the sentences.
  1. How long is the Columbia River?
  2. How far is Korea from China?
  3. How hot is the Sahara Desert? Does it get to 400 Celcius?
  4. How deep is the Caspian Sea.
  5. How high is Mt. Kilimanjaro? Is it more than 5,895 meters?

UNIT 13


This activity practices Grammar Focus : Modal verbs for requests.
Question                                        ==> Answer
What would you like to drink?                ==> I'd like tea.
What flavor would you like?                   ==> I'd like chocolate.
What kind of dressing would you like?   ==> I'd like vinaigrette.
What kind of potatoes would you like?   ==> I'll have French fries, please.
Would you like chicken or fish?              ==> I'll have the chicken.

This activity practices Grammar Focus : So, too, neither, either.
Complete the conversations with so, too, neither, or either.
  1. A: I love Indian food.
    B: So do I.
  2. A: I'm not in the mood for fast food.
    B: Neither am I.
  3. A: I can't stand bland food.
    B: I can't too.
  4. A: I'm crazy about rich desserts.
    B: I am, either.
  5. A: I think pizza is delicious.
    B: So do I.
  6. A: I don't eat enough healthy food.
    B: I don't too.