RSS

Tugas Mandiri 2 Pemrograman Dasar

Source Code :
uses wincrt;
label menu;
type handphone=record
     kodehp,namahp:string[20];
     hargahp:real;
     stokhp:byte;
     end;
     a=array [byte] of handphone;
var hp:a;     
    pil,n,i:byte;
    namahp2:string;
    stokhp2,jml:byte;
    byr,tot,kmbl:real;
    b:char;
begin menu:
      clrscr;
      writeln('..:: Menu Pilihan ::..');
      writeln;
      writeln('1. Input Data HandPhone ');
      writeln('2. Cek Data HandPhone ');
      writeln('3. Membeli HandPhone ');
      writeln;
      pil:=5;
      while (pil<0) or (pil>4) do
      begin
        Write('Masukkan Pilihan Anda ? ');readln(pil);
      end;

  case pil of
  1: begin clrscr;
       b:='y';
       repeat
         inc(n);
         write ('Kode Handphone  = ');readln(hp[n].kodehp);
         write ('Nama Handphone  = ');readln(hp[n].namahp);
         write ('Harga Handphone = ');readln(hp[n].hargahp);
         write ('Stok Handphone  = ');readln(hp[n].stokhp);
         writeln;
         write ('Ingin Memasukkan Data Handphone Lagi [y/t] ? ');readln(b);
         writeln;
       until b='t';
       goto menu;
     end;
  2: begin clrscr;    
        writeln('===================================================');
        writeln('No   Kode      Nama          Harga           Stok  ');
        writeln('===================================================');           
        for i:=1 to n do with hp[i] do
        begin
           writeln(i,'    ',kodehp:3,'     ',namahp:8,'        ',hargahp:6:2,'        ',stokhp:3);
        end;
        {cek daftar HandPhone}
        begin
           write('Masukkan Nama HandPhone = ');readln(namahp2);
           for i:=1 to n do with hp[i] do
           begin
              if namahp2=namahp then
              writeln('HandPhone ',namahp,' berada pada No ',i,' dengan Harga Rp. ',hargahp:6:2);
           end;
           writeln;
           write('Kembali ke Menu [y/t] ? ');readln(b);
           if b='y' then goto menu
           else
           writeln;
           write('               ..*" Matur Nuwun "*..    ');
        end;
     end;

  3: begin clrscr;
        writeln('===================================================');
        writeln('No   Kode      Nama          Harga           Stok  ');
        writeln('===================================================');
        for i:=1 to n do with hp[i] do
        begin
           writeln(i,'    ',kodehp:3,'     ',namahp:8,'        ',hargahp:6:2,'        ',stokhp:3);
        end;
        {Membeli HandPhone}
        begin
           writeln;
           write('Nama HandPhone yang dibeli   = ');readln(namahp2);
           write('Jumlah HandPhone yang dibeli = ');readln(stokhp2);
           write('Uang yang Dibayarkan         = ');readln(byr);                                                                   
           begin
             for i:=1 to n do with hp[i] do
             begin
              if namahp2=namahp then
               begin
                 jml:=stokhp-stokhp2;
                 tot:=stokhp2*hargahp;
                 kmbl:=byr-tot;
                 writeln;
                 writeln('"Anda membeli HandPhone ',namahp2,' dengan jumlah ',stokhp2,' Barang".');
                 writeln('Total Bayar           = ',tot:6:2);
                 writeln('Uang yang Dibayarkan  = ',byr:6:2);
                 writeln('Uang Kembali          = ',kmbl:6:2);
                 writeln;
               end;
             end;
           end;
           write('Kembali ke Menu [y/t] ? ');readln(b);
           if b='y' then goto menu;
        end;
     end;
  end;
end.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar

Berita Terpopuler

  • Welcome Message

Tugas Mandiri 2 Pemrograman Dasar

| Kamis, 19 Mei 2011 |

Source Code :
uses wincrt;
label menu;
type handphone=record
     kodehp,namahp:string[20];
     hargahp:real;
     stokhp:byte;
     end;
     a=array [byte] of handphone;
var hp:a;     
    pil,n,i:byte;
    namahp2:string;
    stokhp2,jml:byte;
    byr,tot,kmbl:real;
    b:char;
begin menu:
      clrscr;
      writeln('..:: Menu Pilihan ::..');
      writeln;
      writeln('1. Input Data HandPhone ');
      writeln('2. Cek Data HandPhone ');
      writeln('3. Membeli HandPhone ');
      writeln;
      pil:=5;
      while (pil<0) or (pil>4) do
      begin
        Write('Masukkan Pilihan Anda ? ');readln(pil);
      end;

  case pil of
  1: begin clrscr;
       b:='y';
       repeat
         inc(n);
         write ('Kode Handphone  = ');readln(hp[n].kodehp);
         write ('Nama Handphone  = ');readln(hp[n].namahp);
         write ('Harga Handphone = ');readln(hp[n].hargahp);
         write ('Stok Handphone  = ');readln(hp[n].stokhp);
         writeln;
         write ('Ingin Memasukkan Data Handphone Lagi [y/t] ? ');readln(b);
         writeln;
       until b='t';
       goto menu;
     end;
  2: begin clrscr;    
        writeln('===================================================');
        writeln('No   Kode      Nama          Harga           Stok  ');
        writeln('===================================================');           
        for i:=1 to n do with hp[i] do
        begin
           writeln(i,'    ',kodehp:3,'     ',namahp:8,'        ',hargahp:6:2,'        ',stokhp:3);
        end;
        {cek daftar HandPhone}
        begin
           write('Masukkan Nama HandPhone = ');readln(namahp2);
           for i:=1 to n do with hp[i] do
           begin
              if namahp2=namahp then
              writeln('HandPhone ',namahp,' berada pada No ',i,' dengan Harga Rp. ',hargahp:6:2);
           end;
           writeln;
           write('Kembali ke Menu [y/t] ? ');readln(b);
           if b='y' then goto menu
           else
           writeln;
           write('               ..*" Matur Nuwun "*..    ');
        end;
     end;

  3: begin clrscr;
        writeln('===================================================');
        writeln('No   Kode      Nama          Harga           Stok  ');
        writeln('===================================================');
        for i:=1 to n do with hp[i] do
        begin
           writeln(i,'    ',kodehp:3,'     ',namahp:8,'        ',hargahp:6:2,'        ',stokhp:3);
        end;
        {Membeli HandPhone}
        begin
           writeln;
           write('Nama HandPhone yang dibeli   = ');readln(namahp2);
           write('Jumlah HandPhone yang dibeli = ');readln(stokhp2);
           write('Uang yang Dibayarkan         = ');readln(byr);                                                                   
           begin
             for i:=1 to n do with hp[i] do
             begin
              if namahp2=namahp then
               begin
                 jml:=stokhp-stokhp2;
                 tot:=stokhp2*hargahp;
                 kmbl:=byr-tot;
                 writeln;
                 writeln('"Anda membeli HandPhone ',namahp2,' dengan jumlah ',stokhp2,' Barang".');
                 writeln('Total Bayar           = ',tot:6:2);
                 writeln('Uang yang Dibayarkan  = ',byr:6:2);
                 writeln('Uang Kembali          = ',kmbl:6:2);
                 writeln;
               end;
             end;
           end;
           write('Kembali ke Menu [y/t] ? ');readln(b);
           if b='y' then goto menu;
        end;
     end;
  end;
end.


0 komentar:

Posting Komentar

Label

Tags: