Wednesday, October 26, 2022

Algoritma dan Struktur Data Pertemuan 6

 Assalamualaikum wr.wb                                                                                                                                                                                                                 


Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1

                                                      Lampiran Contoh 1 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>


void main()
{
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int a;
   for (a=1;a<=10;a++){
    cout<<"Ini adalah baris ke -"<<a<<endl;
   }
   getch();
}

Contoh 2

                                                                            Lampiran Contoh 2 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

puts("=========================");
   puts("  Program For Bersarang  ");
   puts("=========================");
   int a,b;
   for (a=1;a<=2;a++){
    for (b=1;b<=2;b++){
      printf("Latihan Algoritma\n");
      }
   }
   getch();
}

Contoh 3


                                                            Lampiran Contoh 3 sofware Borland C++

#include <iostream.h>
#include <stdio.h>
#include <conio.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int a,b;
   for(a=1;a<=8;a++){
    printf("\n");
      for(b=a;b<=8;b++){

      printf("%d",a);
   }
 }
 getch();
}

Contoh 4


                                                            Lampiran Contoh  4 sofware Borland C++

#include <iostream.h>
#include <stdio.h>
#include <conio.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int a,b;
   char lagi;
atas:
clrscr();
   cout<<"Masukan Bilangan =";cin>>a;
   b=a%2;
   printf("Nilai %d %%2 adalah=%d",a,b);
   printf("\n\n Ingin Hitung Lagi [Y/T]:");
   lagi=getche();
   if(lagi=='Y'|| lagi=='y'){goto atas;}
   getch();
}

Contoh 5


                                                            Lampiran Contoh  5 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM : 3420227001

    int bil = 1;
    while (bil<=10)
    {
    printf (" %d ",bil);
      bil++;
    }
    bil = 2;
    cout<<endl;
    do
    {
    printf (" %d ",bil);
      bil+=2;
    } while (bil <=10);
   getch();
}

Contoh 6


                                                            Lampiran Contoh  6 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM  : 3420227001

int bil = 2;
   int b=0;
   do
   {
    if (bil <20) { printf (" %d +",bil); }
else {printf (" %d = ",bil); }
      b = b + bil;
      bil = bil + 2;
    }
   while (bil<=20);
   cout<<b;
   getch();
}

Contoh 7


                                                            Lampiran Contoh  7 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM  : 3420227001

    int a,b,c;
    for (a=2;a<=10;a+=2)
    {
    b=2; c=0;
    do
    {
      c = c + b;
         if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" + ";}
         b = b + 2;
}
while (b<=a);
cout<<endl;
}
getch();
}

Contoh 8


                                                            Lampiran Contoh  8 sofware Borland C++


#include <stdio.h>
#include <conio.h>
#include <iostream.h>


void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM  : 3420227001

    int a,b,c;
    for (a=1;a<=9;a+=2)
    {
    b=1; c=1;
      do
      {
      c = c * b;
         if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" * ";}
         b = b + 2;
  }
  while (b<=a);
  cout<<endl;
  }
  getch();
}
                                                 Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb

Friday, October 14, 2022

Algoritma dan Struktur Data Pertemuan 5

 Assalamualaikum wr.wb                                                                                                                                                                                                                 


Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1


                                                            Lampiran Contoh 1 sofware Borland C++

include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

//Nama : Muhamad Syarif Ramadhan
//Nim  : 3420227001

char kode,lagi;

atas:
clrscr();
   cout<<"Masukan Kode Menu Makanan [A/B/C]";
   kode =getche();
   cout<<'\n';
   switch (kode){
    case'A':case 'a':
      cout<<"Ayam Bakar"; break;
      case'B':case 'b':
      cout<<"Nasi Goreng"; break;
      case'C':case 'c':
      cout<<"Soto Betawi"; break;
      default:
      cout<<"Anda Salah Masukan Kode";
   }
   cout<<'\n';
   cout<<"\nIngin Pilih Lagi [Y/T]:";
   lagi=getche();
   if(lagi=='Y'||lagi=='y')goto atas;
   getch();
}

Contoh 2

                                                                            Lampiran Contoh 2 sofware Borland C++

#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){
//Nama : Muhamad Syarif Ramadhan
//Nim  : 3420227001

   char kode,lagi; char menu[50],bonus[50];
   int jml; float harga,total,pot,ppn,grand;
lagi:
clrscr();
   printf("Masukan Menu Makanan[1/2/3]:");cin>>kode;
   printf("Jumlah Pembelian Makanan   :");cin>>jml;
   switch(kode){
    case '1':
      strcpy(menu,"Combo Fire Chicken");harga=35000;
         break;
      case '2':
      strcpy(menu,"Combo Fire Wings");harga=33000;
         break;
      default:
      strcpy(menu,"Combo Duo Fire Chicken");harga=50000;
   }
   total=harga*jml;ppn=0.1*total;

   if(jml>5){
    strcpy(bonus,"Tumbler");
      pot=0.1*total;
   } else {
    strcpy(bonus,"Maaf Tidak Dapat Bonus");
      pot=0;
   }
   grand=total+ppn-pot;
   clrscr();
   puts("           RICHEESE FACTORY");
   puts("         Jl.Pekayon Raya No.106");
   puts("====================================");
   cout<<"Menu Makanan  :"<<menu<<endl;
   cout<<"Harga Menu    :"<<harga<<endl;
   cout<<"Bonus         :"<<bonus<<endl;
   cout<<"Total Bayar   :"<<total<<endl;
   cout<<"Potongan      :"<<pot<<endl;
   cout<<"PPN           :"<<ppn<<endl;
   cout<<"Grand Total   :"<<grand<<endl;
   puts("=====================================");
   puts("           Terima Kasih");
   cout<<"        Ingin Pesan Lagi.?";cin>>lagi;
   if (lagi== 'Y' || lagi=='y'){goto lagi;}
   getch();

}

Contoh 3


                                                            Lampiran Contoh 3 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main(){
//Nama : Muhamad Syarif Ramadhan
//Nim  : 3420227001

char nama[30],tipe[30],souvenir[20];
   char kode,lagi;
   int lama;
   float harga,total,admin=150000,ubay,ukem;

awal:

clrscr();
   puts("HOTEL BINTANG LIMA");
   puts("===================================");
   cout<<"Nama Penyewa        :";cin>>nama;
   cout<<"Kode Kamar [S/T/D]  :";cin>>kode;

   if (kode=='S' || kode=='s')
   {
    strcpy(tipe,"Single Room");
      harga=200000;
   }
   else if (kode=='T' || kode=='t')
   {
      strcpy(tipe,"Twim Room");
      harga=300000;
   }
   else if (kode=='D' || kode=='d')
   {
    strcpy(tipe,"Double Room");
      harga=450000;
   }
   else
   {
    puts("============================");
      cout<<"Kode Kamar Yang Anda Masukan Salah, Silahkan Input lagi";
      cin>>lagi;
      switch(lagi)
      {
      case'Y':
         case'y':
          goto awal;
         default:
          goto akhir;
      }
   }

   clrscr();
   puts("HOTEL BINTANG LIMA");
   puts("============================");
   cout<<"Nama Penyewa      :"<<nama<<endl;
   cout<<"Kode Kamar [S/T/D]:"<<kode<<endl;
   cout<<"Lama Menginap     :";cin>>lama;
   puts("============================");

   if(lama>=7)
   {
    strcpy(souvenir,"Tas Ransel");
   }
   else
   {
    strcpy(souvenir,"Tidak Dapat");
   }
   total=(harga*lama)+ admin;
   cout<<"Tipe Kamar \t\t:" <<tipe<<endl;
   cout<<"Lama Menginap \t\t:"<<lama<<"hari"<<endl;
   cout<<"Souvenir \t\t:"<<souvenir<<endl;
   printf("Biaya Sewa \t\t: Rp.%8.2f\n",harga);
   printf("Biaya Administrasi \t: Rp.%8.2f\n",admin);
   printf("Total Biaya Sewa \t: Rp.%8.2f\n",total);
   puts("==============================");
   cout<<"Uang Bayar :";cin>>ubay;
   ukem=ubay-total;
   cout<<"Uang Kembali:"<<ukem<<endl;
   cout<<"Ingin Input lagi [Y/T]";cin>>lagi;
   switch(lagi)
   {
    case'Y':
      case'y':
      goto awal;
      default:
      goto akhir;
   }

akhir:
getch();
}

                                                Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb

Sunday, October 2, 2022

Algoritma dan Struktur Data Pertemuan 4

  Assalamualaikum wr.wb                                                                                                                                                                                                                 


Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1


                                                            Lampiran Contoh 1 sofware Borland C++

#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main() {
//Nama : Muhamad Syarif Ramadhan
//Nim : 3420227001

int absen,tugas,uts,uas;
   float total;
   puts("Program Menghitung Nilai Mahasiswa");
   puts("++++++++++++++++++++++++++++++++++");
   printf("Masukan Nilai Absen:");scanf("%d",&absen);
   printf("Masukan Nilai Tugas:");scanf("%d",&tugas);
   printf("Masukan Nilai UTS:");scanf("%i",&uts);
   printf("Masukan NIlai UAS:");scanf("%I",&uas);
total=(absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);
   puts("++++++++++++++++++++++++++++++++++");
   printf("Total Adalah:%.2f(Bentuk Tidak Terformat)\n",total);
   printf("Total Adalah:%.2f(Bentuk Yang Terhormat)\n",total);
   puts("++++++++++++++++++++++++++++++++++");
   if (total>=75)
   {cout<<"Selamat Kamu Lulus.";}
   else
   {cout<<"Maaf Kamu Tidak Lulus.";}
   getch();
   }

Contoh 2

                                                                            Lampiran Contoh 2 sofware Borland C++




#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

// Nama : Muhamad Syarif Ramadhan
// Nim  : 3420227001


      int pilih;
      char huruf [20];
      printf ("Silakan Pilih Program [1/2]:") ; cin >> pilih;
      if (pilih == 1){
      clrscr();
                        puts ("+++++++++++++++++++++++++");
                        puts ("\Contoh Program Strlen");
                        puts ("+++++++++++++++++++++++++");
                        cout <<"Masukan Sembarang Kata = "; gets (huruf);
                        cout <<"Panjang Kata Yang Diinput = "<<strlen(huruf);
      getch() ;
      }
      else if (pilih == 2){
      clrscr();
puts ("+++++++++++++++++++++++++");
puts ("\Contoh Program Strcmp");
puts ("+++++++++++++++++++++++++");
char a1 [] = "Z";
char a2 [] = "z";
char b1 [] = "Z";
cout <<"Hasil Perbandingan "<<a1<<" dan "<<a2<< "->";
cout <<strcmp (a1,a2) <<endl;
cout <<"Hasil Perbandingan "<<a2<<" dan "<<a1<< "->";
cout <<strcmp (a2,a1) <<endl;
cout <<"Hasil Perbandingan "<<a1<<" dan "<<b1<< "->";
cout <<strcmp (a1,b1) <<endl;
getch();
    }
}

Contoh 3


                                                            Lampiran Contoh 3 sofware Borland C++

#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

// Nama : Muhamad Syarif Ramadhan
// Nim  : 3420227001

char gol,jab[10];
long gapok;
   cout<<endl<<"Data Jabatan"<<endl
<<"++++++++++++++++++++++++++"<<endl;
cout<<"Masukan Golongan [1/2]: ";cin>>gol;
if(gol=='1'){
strcpy(jab,"Manajer");
gapok=6000000;
}
else if(gol=='2'){
strcpy(jab,"Karyawan");
gapok=4500000;
}
else{
printf("Golongan %c tidak terdaftar.\n",gol);
strcpy(jab,"None");
gapok=0;
}
cout<<"Jabatan = "<<jab<<endl;
cout<<"Gaji Pokok = "<<gapok<<endl;
getch();
   }

Contoh 4


                                                            Lampiran Contoh 4 sofware Borland C++
#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

// Nama : Muhamad Syarif Ramadhan
// Nim  : 3420227001

char kode,ukuran,merk[15]="None";
long harga=0;
cout<<"Kode Baju [1/2] : ";cin>>kode;
cout<<"Ukuran [S/M] : ";cin>>ukuran;
if (kode=='1'){
    strcpy(merk, "Converse");
if (ukuran=='S' || ukuran == 's') {harga=200000;} else {harga=210000;}
}
else if (kode=='2'){
strcpy(merk,"Nike");
//Bentuk penulisan if versi singkat
if (ukuran=='S' || ukuran == 's') harga=600000; else harga=610000;
   }
else{
cout<<"Salah Kode Baju"<<endl;
}
cout<<"Merk Baju :"<<merk<<endl;
cout<<"Harga Baju :"<<harga<<endl;
getch();
}
                                                  
                                                  Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb