TUGAS ALGORITMA DAN STRUKTUR DATA PERTEMUAN 4

 TUGAS 3 PERTEMUAN KE 4 ALGORITMA DAN STRUKTUR DATA


Nama    : Mahfud Muhyiddin

Prodi     : Informatika

NIM      : 3420210025


Lampiran Tugas 3.1

                                                                            Program 3.1

Script Tugas 3.1

#include <stdio.h>

#include <iostream.h>

#include <conio.h>

// Nama    : Mahfud Muhyiddin

// Nim      : 3420210025

// Prodi     : Teknik Informatika


  void main()

  {

  //Deklarasi

      int absen, tugas, uts, uas;

      float total;


      puts ("Program Menghitung Nilai Mahasiswa");

      puts ("-----------------------------------");

      printf ("Masukan Nilai Absen"); scanf ("%d",& absen);

      cout <<"Masukan Nilai Tugas"; cin>> tugas;

      printf ("Masukan Nilai UTS"); scanf ("%i",& uts);

      cout <<"Masukan Nilai UAS"; cin>> uas;


      //Proses Perhitungan

      total = (absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);

      puts ("-----------------------------------");

      cout<< "Total Adalah: " <<total<< "(bentuk tidak terformat)\n";

      printf ("Total Adalah: %.2f (bentuk terformat)\n", total);

      puts ("-----------------------------------");


      //Kondisi

      if (total>=75)

      { cout <<"Selamat Anda Lulus."; }

      else

      { cout <<"Maaf Anda Tidak Lulus.";}


  getch() ;

  }

Lampiran Tugas 3.2

Program 3.1


Program 3.2.2


Program 3.2.3


Program 3.2.4


Script Tugas 3.2

#include <stdio.h>

#include <iostream.h>

#include <conio.h>


  // Nama : Mahfud Muhyiddin

  // Nim    : 3420210025

  // Prodi : Teknik Informatika


  void main()

  {

  int pilih;

      char huruf [20];


      printf ("Silakan Pilih Program [1/2]:") ; cin >> pilih;

      //scanf ("%d", & pilih);

      /*

      There are two problems with using scanf() to get a number:

         First, validation/error handling is poor.

         The second problem is that of leaving characters in the buffer.

         Sumber: https://faq.cprogram.com/cgi-bin/smartfaq.cgi?answer=1043372399&id=1043284385

      */

    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 [] = "S";

         char a2 [] = "s";

         char b1 [] = "S";

         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();

      }

      else

      {

      printf ("Maaf Pilihan Anda Salah..");

      }

   }

Lampiran Tugas 3.3

Program 3.3.1


Program 3.3.2

Script Tugas 3.3

#include <stdio.h>

#include <conio.h>

#include <iostream.h>



//Nama : Mahfud Muhyiddin

//NIM    : 3420210025

//Prodi : Teknik Informatika



void main ()


{


char gol,jab[10];


   long gapok;


   cout<<endl<<"Data Jabatan"<<endl


   <<" - - - - - - - - - - - - - - - - "<<endl;


   cout<<"Masukan Golongan [1/2]: ";cin>>gol;


   if(gol=='1')


   {


    strcpy(jab,"Direktur");


      gapok=200000000;


   }


   else if(gol=='2')


   {


    strcpy(jab,"Manajer");


      gapok=8000000;


   }


   else


   {


    printf("Golongan %c tidak terdaftar.\n",gol);


      strcpy(jab,"None");


      gapok=0;


   }


   cout<<"Jabatan = "<<jab<<endl;


   cout<<"Gaji Pokok = "<<gapok<<endl;


   getch();


}

Lampiran Tugas 3.4

Program 3.4.1


Program 3.4.2

Script Tugas 3.4

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

//Nama : Mahfud Muhyiddin
//NIM    : 3420210025
//Prodi : Teknik Informatika

void main ()

{

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, "zara");

      if (ukuran=='S' || ukuran == 's') {harga=200000;} else {harga=210000;}

   }

   else if (kode=='2')

   {

    strcpy(merk,"supreme");

      //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();

}

Komentar

Postingan populer dari blog ini