Jumat, 21 Oktober 2022

Script Pertemuan 6

SCRIPT PERTEMUAN 6

CONTOH 1

/* --------------------------- */
/* Program for - Bilangan Naik */
/* --------------------------- */
   #include <stdio.h>
   #include <conio.h>
   #include <iostream.h>

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

CONTOH 2

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

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

CONTOH 3

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

   void main()
   {
      int a,b;
      for (a=1;a<=5;a++)
      {
        printf ("\n");
      for (b=a;b<=5;b++)
         {
      printf("%d",a);
         }
      }
      getch();
   }

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

   void main()
   {
      int a,b;
      char lagi;

   atas:
      clrscr();
      cout << "Masukkan 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

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

   void main()
   {
      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

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

   void main()
   {
      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
   
   #include <iostream.h>
   #include <stdio.h>
   #include <conio.h>

   void main()
   {
      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

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

   void main()
   {
      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();
   }

KALAU ADA ERROR SILAKAN KOMEN...
TERIMA KASIH :)

Tugas 4 (Pertemuan 5) Algoritma dan Struktur Data

 Algoritma dan Struktur Data

Tugas 4 Programing Basic Algoritma



Assalamu'alaikum Wr. Wb.

Nama      : Aufa Munadil Al - Khoir
NIMa      : 3420210024
Prodi       : Teknik Informatika
Fakultas  : Sains dan Teknologi

Lampiran Tugas 4 Algoritma & Struktur Data


Example 1
Script Ex 1

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

void garis();
void main()
{
char code,again;    // Nama  : Aufa Munadil Al - Khoir
                            // NIM   : 3420210024
//Deklarasi Label   // Prodi : Teknik Informatika
atas:
clrscr();
   garis();
cout << "\t   INPUT CODE CAR [X/Y/Z]: ";
   code = getche();
   cout << '\n';
   garis();
   cout << "\t = =  ";
   switch (code)
   {
    case 'X': case 'x':
    cout << "SPORT CAR"; break;
    case 'Y': case 'y':
      cout << "SUPER CAR"; break;
    case 'Z': case 'z':
      cout << "OFF ROAD CAR"; break;
    default:
      cout << "CAR CODE NOT AVAILABLE \n";
}
cout << '\n';
      garis();
cout << "\n\t CHOOSE AGAIN [R/N]: ";
again = getche();
if(again == 'R' || again == 'r') goto atas;
      getch();
}
void garis()
{
cout << "\t = = = = = = = = = = = = = = = \n";
}


Example 2


Script Ex 2

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

void garis();     // Nama  : Aufa Munadil Al - Khoir
void line();      // NIM   : 3420210024
void main()       // Prodi : Teknik Informatika
{
char code,again; char name[50],bonus[50];
int jml; float price,total,piece,ppn,grand;
again:

clrscr();
   line();
printf("\t Masukan code Buku [S/R/F]: ");cin>>code;
printf("\t Jumlah Pembelian Buku    : ");cin>>jml;
switch (code)
   {
case 'S':
strcpy(name,"Rahasia Dunia yang Disembunyikan");
price = 158000;
break;

case 'R':
strcpy(name,"Strungle Off Life");
price = 45000;
break;

case 'F':
strcpy(name,"Find the Someone");
price = 45000;

    default:
      strcpy(name,"Kode Belum Tersedia");
         price = 0;
}
total = price * jml; ppn = 0.1 * total;

if(jml>3) {
strcpy(bonus,"Totebag");
piece = 0.1 * total;
} else {
strcpy(bonus,"Maaf Tidak Dapat Bonus");
piece = 0;
}
grand = total + ppn - piece;

clrscr();
   garis();
puts   ("\t            *** Ayu Bookstore ***");
puts   ("\t       Jl. Kesuksesan Batu Permata No.23");
garis();
cout << "\t Name Book   : " << name  << endl;
cout << "\t Price Book  : " << price << endl;
cout << "\t Bonus       : " << bonus << endl;
cout << "\t Total Pay   : " << total << endl;
cout << "\t Discount    : " << piece << endl;
cout << "\t PPN         : " << ppn   << endl;
cout << "\t Grand Total : " << grand << endl;
garis();
puts   ("\t              *** Thank You ***");
cout << "\t                 Input Again "; cin >> again;
if (again == 'Y' || again=='y') {goto again; }
getch();
}
void garis(){
cout << "\t - - - - - - - - - - - - - - - - - - - - - - - \n";
}
void line(){
cout << "\t # # # # # # # # # # # # # # # # # # # # # # # \n";
}


Example 3


Script Ex 3

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

void garis();   // Nama  : Aufa Munadil Al - Khoir
void line();    // NIM   : 3420210024
void main()     // Prodi : Teknik Informatika
{
   char name[92], type[29], souvenir[92];
   char code, again;
   int lama;
   float price, total, admin=100000, pym, rfnd;

awal:

   clrscr();
   line();
   puts   ("\t ~ ~ ~ ~ ~       HOTEL BATU PERMATA BIRU       ~ ~ ~ ~ ~");
   line();
   cout << "\t Tenant Name              : ";cin>>name;
   cout << "\t Room Code [S/A/P]        : ";cin>>code;

   if (code == 'S' || code == 's')
   {
      strcpy(type,"Superior Room");
      price = 2300000;
   }
   else if (code == 'A' || code == 'a')
   {
      strcpy(type,"Smoking and Non-Smoking Room");
      price = 1300000;
   }
   else if (code == 'P' || code == 'p')
   {
      strcpy(type,"Penthous Room");
      price = 9200000;
   }
   else
   {
      line();
      cout << "\t The Room Code you Entered is Wrong.\n\t Want to Enter Again? ";
      cin >> again;
      switch(again)
      {
      case 'Y':
      case 'y':
          goto awal;
        default:
          goto akhir;
      }
   }


   clrscr();
   line();
   puts   ("\t ~ ~ ~ ~ ~       HOTEL BATU PERMATA BIRU       ~ ~ ~ ~ ~");
   line();
   cout << "\t Tenant Name              : "<<name<<endl;
   cout << "\t Room Code [S/A/P]        : "<<code<<endl;
   cout << "\t Length of Stay           : ";cin>>lama;
   garis();
   if (lama>=12)
   {
    strcpy(souvenir,"Roxy Watch");
   }
   else
   {
    strcpy(souvenir,"Haverst Package");
   }

   total = (price * lama) + admin;

   cout << "\t Type Room                : " << type <<endl;
   cout << "\t Length of Stay           : " << lama << " Day" << endl;
   cout << "\t Souvenir                 : " << souvenir <<endl;
   printf ("\t Rental Cost              : Rp. %8.2f \n",price);
   printf ("\t Administrative Cost      : Rp. %8.2f \n",admin);
   printf ("\t Total Rental Cost        : Rp. %8.2f \n",total);
   garis();
   cout << "\t Pay Money                : Rp. ";cin>>pym;
   rfnd = pym - total;
   cout << "\t Refund                   : Rp. "<<rfnd<<endl;
   cout << "\t Want to Enter Again [Y/T]: ";cin>>again;
   switch(again)
   {
    case 'Y':
      case 'y':
          goto awal;
      default:
          goto akhir;
   }
akhir:
getch();
}
void garis(){
cout << "\t . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n";
}
void line(){
cout << "\t ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \n";
}


Wassalamu'alaikum Wr. Wb.
Silakan Berikan Kritik dan Sarannya :)
Thank You

Minggu, 02 Oktober 2022

Tugas 3 (Pertemuan 4) Algoritma dan Struktur Data

 

Algoritma & Struktur Data

Tugas 3 Progaming Basic Algoritma

 

Assalamualaikum Wr. Wb.

Nama      : Aufa Munadil Al - Khoir
NIMa      : 3420210024
Prodi       : Teknik Informatika
Fakultas  : Sains dan Teknologi


Lampiran Tugas 3 Algoritma & Struktur Data

Example 1
Program_Menghitung_Nilai_Mahasiswa

Script Ex 1

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

void main ()
{
   //Keterangan_Variable          //Nama  : Aufa Munadil Al - Khoir
   int absen, tugas, uts, uas;    //NIM   : 3420210024
   float total;                   //Prodi : Teknik Informatika

   printf ("\t////////////////////////////////////////////\n");
   puts ("\t//// Program_Menghitung_Nilai_Mahasiswa ////");
   printf ("\t////////////////////////////////////////////\n");

   cout<<endl;
   printf ("\tInput_Value_Absen : "); scanf("%d",&absen);
   printf ("\tInput_Value_Tugas : "); scanf("%i",&tugas);
   cout <<"\tInput_Value_UTS  : "; cin>>uts;
   cout <<"\tInput_Value_UAS : "; cin>>uas;

   cout<<endl;
   //Proses_Penghitungan
   total = (absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);

   puts  ("\t############################################");
   cout <<"\tTotal_Adalah : "<<total<<" (Non_Format)\n";
   printf ("\tTotal_Adalah      : %.2f (Format)\n",total);
   puts ("\t############################################\n");

   //Kondisi
   if (total >=75)
   { cout<<"\tCongratulations"<<endl; }
   else
   { cout<<"\tSorry_You_Didn't_Pass"<<endl; }

   cout <<"\t\t\t\t\tCreate By  :"<<endl;
   printf ("\t********************************************\n");
   cout <<"\t*******   Aufa Munadil Al - Khoir    *******" <<endl;
   cout <<"\t*******          3420210024          *******" <<endl;
   cout <<"\t*******      Teknik Informatika      *******" <<endl;
   cout <<"\t******* project-s-khopi.blogspot.com *******" <<endl;
   printf ("\t********************************************\n");

   getch();
}

Example 2
Programs_1_Strlen

Programs_2_Strcmp


Script Ex 2

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

void main ()
{                                //Nama  : Aufa Munadil Al - Khoir
   int pilih;                    //NIM   : 3420210024
   char huruf[92];               //Prodi : Teknik Informatika
   cout<<endl;
   printf("\t\t# # # # # # # # # # # # # # # # # # # # # # # # # #\n");
   printf("\t   Choice_Your_Programs [1/2]: ");cin>>pilih;
   //scanf("%d",&pilih);

   if (pilih == 1)
   {
      clrscr();
      puts ("\t\t# # # # # # # # # # # # # # # # # # # # # # # # # #");
      puts ("\t\t# # # # # # # Example_Strlen_Programs # # # # # # #");
      puts ("\t\t# # # # # # # # # # # # # # # # # # # # # # # # # #");
      cout <<endl;
      cout <<"\t\tInput_Text          = ";gets(huruf);
      cout <<"\t\tEntered_Text_Lenght = "<<strlen(huruf);
      cout <<endl<<endl;
      cout <<"\t\t\t\t\t\t\t Create By:"<<endl;
      printf("\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *\n");
      cout   <<"\t\t* * * * *  'project-s-khopi.blogspot.com  * * * * *"<<endl;
      printf("\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *\n");

      getch();
   }

else if (pilih == 2)
   {
      clrscr();
      puts ("\t\t$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $");
      puts ("\t\t$ $ $ $ $ $ $ Example_Strcmp_Programs $ $ $ $ $ $ $");
      puts ("\t\t$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $");
      char f1[] = "f";
      char f2[] = "F";
      char f3[] = "f";
      cout <<endl;
      cout <<"\t Hasil Perbandigan "<<f1<<" dan "<<f2<<"-> ";
      cout <<strcmp (f1,f2)<<endl;
      cout <<"\t Hasil Perbandigan "<<f2<<" dan "<<f1<<"-> ";
      cout <<strcmp (f2,f1)<<endl;
      cout <<"\t Hasil Perbandigan "<<f1<<" dan "<<f3<<"-> ";
      cout <<strcmp (f1,f3)<<endl;
      cout <<endl;
      printf("\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *\n");
      cout   <<"\t\t* * * * *  'project-s-khopi.blogspot.com  * * * * *"<<endl;
      printf("\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *\n");
      getch();
   }
   else
   {
      printf("\t    Sorry_Your_Choice_Is_Wrong");
      getch();
   }
}

Example 3
Program_Biaya_Kuliah
Menggunakan_String_Strcpy

Script Ex 3

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

void main()
{                                 //Nama : Aufa Munadil Al - Khoir
   char type,faculty[29];         //NIM  : 3420210024
   long spp;                      //Prodi: Teknik Informatika

   cout<<endl;
   cout <<"\tX X X X X X X X X X X X X X X X X X"<<endl;
   cout  <<"\tX X X X X   Faculty_Fee   X X X X X"<<endl;
   cout <<"\tX X X X X X X X X X X X X X X X X X"<<endl;
   cout <<"\t    Input_Your_Type [F/K/U]: ";cin>>type;
   if(type=='F')
   {
      strcpy(faculty,"Science and Technology");
      spp=21000000;
   }
   else if(type=='K')
   {
      strcpy(faculty,"Health Sciences");
      spp=27300000;
   }
   else if(type=='U')
   {
      strcpy(faculty,"Islamic Economics_n_Business Law");
      spp=27300000;
   }
   else
   {
      printf("\tFaculty_%c_not_Registerd.\n",type);
      strcpy(faculty,"None");
      spp=999999999;
   }
   cout <<"\tType    : "<<type<<endl;
   cout <<"\tFaculty : "<<faculty<<endl;
   cout <<"\tSPP    : "<<spp<<endl;

   cout<<endl;
   cout  <<"\t\t\t\tCreate By :"<<endl;
   printf ("\t* * * * * * * * * * * * * * * * * *\n");
   cout <<"\t*  'project-s-khopi.blogspot.com  *" <<endl;
   printf ("\t* * * * * * * * * * * * * * * * * *\n");
   getch();
}

Example 4
Program_Memilih_Ukuran_Baju


Script Ex 4

#include <stdio.h>         //Nama  : Aufa Munadil Al - Khoir
#include <conio.h>         //NIM   : 3420210024
#include <iostream.h>      //Prodi : Teknik Informatika

void main()
{

   printf ("\t********************************************\n");
   cout   <<"\t******** 'Clothes_Choosing_Programs ********" <<endl;
   printf ("\t********************************************\n");

   char code, size, merk[15]="None";
   long harga=0;
   cout <<"\tChoice_Code [1/2/3] : ";cin>>code;
   cout <<"\tChoice_Size [S/L/XL] : ";cin>>size;
   if (code=='1')
   {
      strcpy(merk,"KIRA");
      if (size=='S' || size =='s') { harga=754200; } else { harga=949000; }

      strcpy(merk,"KIRA");
      if (size=='L' || size =='l') { harga=885100; } else { harga=989000; }

      strcpy(merk,"KIRA");
      if (size=='XL' || size =='xl') { harga=994200; } else { harga=1249000; }
   }
   else if (code=='2')
   {
      strcpy(merk,"FYZ");
      //Bentuk penulisan if versi singkat
      if (size=='S' || size == 's') harga=130000; else harga=178900;

      strcpy(merk,"FYZ");
      if (size=='M' || size == 'm') harga=700000; else harga=892000;

      strcpy(merk,"FYZ");
      if (size=='XL' || size == 'xl') harga=521000; else harga=950900;
   }
   else if (code=='3')
   {
      strcpy(merk,"ARAH");
      if (size=='S' || size =='s') { harga=890200; } else { harga=1800100; }

      strcpy(merk,"ARAH");
      if (size=='M' || size == 'm') harga=700000; else harga=892000;

      strcpy(merk,"ARAH");
      if (size=='S' || size =='s') { harga=582000; } else { harga=840200; }
   }
   else
   {
    cout<<"\tWrong_Dress_Code"<<endl;
   }
   cout <<"\tMerk Baju            : "<<merk<<endl;
   cout <<"\tHarga Baju          : "<<harga<<endl;

   cout <<"\t\t\t\t\tCreate By  :"<<endl;
   printf("\t********************************************\n");
   cout <<"\t******* project-s-khopi.blogspot.com *******" <<endl;
   printf("\t********************************************\n");
   getch();
}

Terima Kasih
Wassalamu'alaikum Wr. Wb.

Tugas 13 (Pertemuan 14) Algoritma dan Struktur Data

  Algoritma dan Struktur Data Tugas 13 Programing Basic Algoritma Assalamu'alaikum Wr. Wb. Nama        : Aufa Munadil Al - Khoir NIM a  ...