Catatan Praktikum Algoritma pertemuan 1-14 - TeachMeSoft

Catatan Praktikum Algoritma pertemuan 1-14




  Pertemuan 1


Hanya Pengenalan awal, yaitu:
  • Menganal C++
  • Aplikasi yang digunakan (yaitu Codeblocks)
  • Logika sederhana
  • Struktur awal C++



 Pertemuan 2



Tugas ke-1

  • Membuat sebuah program sederhana yang minimal memiliki tipe data, 
  • chat,
  • string
  • int
hasil tugas silakan lihat di daftar isi dibagian algorimat 1 tugas ke-1


 Pertemuan 3


Membuat program yang memiliki
  • inputan
  • outputan
  • tipe data yang digunakan bebas tpi minimal memiliki char, int, string.

berikut hasil akhir nya:


Source code:

#include <iostream>//cin-cout
#include <conio.h> //getch

using namespace std;

int main(){
      char nim[10]; //gunakan cin
      double nohp;
      string ucapan="Selamat Datang", nama, asal, alamat ;

 //masukkan
 cout<<"masukan nama : ";getline(cin, nama); //getline input data lebih dari 1 kata
 cout<<"masukan NIM : ";cin>>nim;
 cout<<"masukan No HP : ";cin>>nohp;
 cout<<"masukan alamat : ";cin>>alamat;
 cout<<"masukan asal   : ";cin>>asal;

 cout<<endl<<endl;

 //Keluaran
 cout<<ucapan<<" "<<nama<<" di CPP"<<endl;
 cout<<nama;
 cout<<"\n Nama   : "<<nama;
 cout<<"\n NIM    : "<<nim;
 cout<<"\n No HP  : "<<nohp;
 cout<<"\n Alamat : "<<alamat;
 cout<<"\n Asal   : "<<asal;


getch; // menahan program
}


Output program:



Tugas ke-2 dirumah;
  1. yang menyertakan input dan output data
  2. mencari program if digoogle
  3. analisa masing-masing program

hasil tugas silakan lihat di daftar isi dibagian algorimat 1 tugas ke-2


 Pertemuan 4

8 okteber 2019

#include <iostream>
#include <conio.h>
//#include <stdlib.h>

using namespace std;

main(){
    string nama1,nama2,nama3,mk1,mk2,mk3;
    long int nim1,nim2,nim3;
    float na1,na2,na3;
    int a;
    char nh1,nh2,nh3;
    cout<<"-------------------------------------------\n";
    cout<<"|                                         |\n";
    cout<<"|          Latihan Program IF             |\n";
    cout<<"|                                         |\n";
    cout<<"-------------------------------------------\n";
    cout<<"NIM         : ";cin>>nim1;
    cout<<"Nama        : ";cin>>nama1;
    cout<<"MK          : ";cin>>mk1;
    cout<<"Nilai Angka : ";cin>>na1;

    cout<<"-------------------------------------------\n";
    cout<<"NIM         : ";cin>>nim2;
    cout<<"Nama        : ";cin>>nama2;
    cout<<"MK          : ";cin>>mk2;
    cout<<"Nilai Angka : ";cin>>na2;

    cout<<"-------------------------------------------\n";
    cout<<"NIM         : ";cin>>nim3;
    cout<<"Nama        : ";cin>>nama3;
    cout<<"MK          : ";cin>>mk3;
    cout<<"Nilai Angka : ";cin>>na3;
    cout<<"-------------------------------------------\n";


    //Untuk Data 1
    if (na1>=85 && na1<=100){
        nh1='A';
        cout<<"-------------------------------------------\n";
    }else if(na1>=75 && na1<=84){
        nh1='B';
        cout<<"-------------------------------------------\n";
    }else if(na1>=60 && na1<=74){
        nh1='C';
        cout<<"-------------------------------------------\n";
    }else if(na1>=50 && na1<=59){
        nh1='D';
        cout<<"-------------------------------------------\n";
    }else if(na1>=0 && na1<=49){
         nh1='E';
        cout<<"-------------------------------------------\n";
    }else{
        cout<<"===========================================\n";
        cout<<"|    Maaf Data yang anda input Salah      |\n";
        cout<<"===========================================\n";
    }


    //Untuk Data 2
    if (na2>=85 && na2<=100){
        nh2='A';
        cout<<"-------------------------------------------\n";
    }else if(na2>=75 && na2<=84){
        nh2='B';
        cout<<"-------------------------------------------\n";
    }else if(na2>=60 && na2<=74){
        nh2='C';
        cout<<"-------------------------------------------\n";
    }else if(na2>=50 && na2<=59){
        nh2='D';
        cout<<"-------------------------------------------\n";
    }else if(na2>=0 && na2<=49){
        nh2='E';
        cout<<"-------------------------------------------\n";
    }else{
        cout<<"===========================================\n";
        cout<<"|    Maaf Data yang anda input Salah      |\n";
        cout<<"===========================================\n";
    }

    //Untuk Data 3
    if (na3>=85 && na3<=100){
    nh3='A';
        cout<<"-------------------------------------------\n";
    }else if(na3>=75 && na3<=84){
        nh3='B';
        cout<<"-------------------------------------------\n";
    }else if(na3>=60 && na3<=74){
        nh3='C';
        cout<<"-------------------------------------------\n";
    }else if(na3>=50 && na3<=59){
        nh3='D';
        cout<<"-------------------------------------------\n";
    }else if(na3>=0 && na3<=49){
        nh3='E';
        cout<<"-------------------------------------------\n";
    }else{
        cout<<"===========================================\n";
        cout<<"|    Maaf Data yang anda input Salah      |\n";
        cout<<"===========================================\n";
    }

    //system("cls");
    cout<<"==========================================="<<endl;
    cout<<"|                                         |"<<endl;
    cout<<"|          Hasil Akhir Mahasiswa          |"<<endl;
    cout<<"|                                         |"<<endl;
    cout<<"==========================================="<<endl;
    cout<<"Nama         : "<<nama1<<endl;
    cout<<"Hilai Huruf  : "<<nh1<<endl;
    cout<<"-------------------------------------------\n";
    cout<<"Nama         : "<<nama2<<endl;
    cout<<"Hilai Huruf  : "<<nh2<<endl;
    cout<<"-------------------------------------------\n";
    cout<<"Nama         : "<<nama3<<endl;
    cout<<"Hilai Huruf  : "<<nh3<<endl;
    cout<<"-------------------------------------------\n";

}

 Pertemuan 5



Menggunakan If

#include <iostream>
#include <conio.h>
//#include <stdlib.h>

using namespace std;

main(){
    string nama,mk1,mk2,mk3,prodi;
    float mkt1, mkt2,tsks,tp;
    int pd,sks1, sks2, sks3;
    long int nim;

    cout<<"-------------------------------------------\n";
    cout<<"Nama             : ";cin>>nama;
    cout<<"NIM              : ";cin>>nim;
    cout<<"Mata Kuliah 1    : ";cin>>mk1;
    cout<<"SKS 1            : ";cin>>sks1;
    cout<<"Mata Kuliah 2    : ";cin>>mk2;
    cout<<"SKS 2            : ";cin>>sks2;
    cout<<"Mata Kuliah 3    : ";cin>>mk3;
    cout<<"SKS 3            : ";cin>>sks3;
    cout<<"-------------------------------------------\n";

    cout<<"Prodi anda"<<endl;
    cout<<" 1 T.Elektro"<<endl;
    cout<<" 2 S.Komputer"<<endl;
    cout<<"Pilih <1/2> : ";cin>>pd;

    if(pd==1){
        mkt1=100000;
        prodi="T.Elektro";
        cout<<"Prodi anda T.Elektro"<<endl;
        tsks=sks1+sks2+sks3;
        tp=tsks*mkt1;
    }else if(pd==2){
        mkt2=110000;
        prodi="S.Komputer";
        cout<<"Prodi anda S.Komputer"<<endl;
        tsks=sks1+sks2+sks3;
        tp=tsks*mkt2;
    }else{
        cout<<"data yang anda input salah"<<endl;
    }

     cout<<"-------------Pembayaran SKS---------------\n";
     cout<<"Nama              : "<<nama<<endl;
     cout<<"NIM               : "<<nim<<endl;
     cout<<"Prodi             : "<<prodi<<endl;
     cout<<"Total SKS         : "<<tsks<<endl;
     cout<<"Total Pembayaran  : Rp. "<<tp<<endl;
     cout<<"-------------------------------------------\n";
}


Menggunakan switch

#include <iostream>
#include <conio.h>
//#include <stdlib.h>

using namespace std;

main(){
    string nama,mk1,mk2,mk3,prodi;
    float mkt1, mkt2,tsks,tp;
    int pd,sks1, sks2, sks3;
    long int nim;

    cout<<"-------------------------------------------\n";
    cout<<"Nama             : ";cin>>nama;
    cout<<"NIM              : ";cin>>nim;
    cout<<"Mata Kuliah 1    : ";cin>>mk1;
    cout<<"SKS 1            : ";cin>>sks1;
    cout<<"Mata Kuliah 2    : ";cin>>mk2;
    cout<<"SKS 2            : ";cin>>sks2;
    cout<<"Mata Kuliah 3    : ";cin>>mk3;
    cout<<"SKS 3            : ";cin>>sks3;
    cout<<"-------------------------------------------\n";

    cout<<"Prodi anda"<<endl;
    cout<<" 1 T.Elektro"<<endl;
    cout<<" 2 S.Komputer"<<endl;
    cout<<"Pilih <1/2> : ";cin>>pd;

    switch(pd){
        case 1:{
            mkt1=100000;
            prodi="T.Elektro";
            cout<<"Prodi anda T.Elektro"<<endl;
            tsks=sks1+sks2+sks3;
            tp=tsks*mkt1;cout<<endl;break;
        }
        case 2:{
            mkt2=110000;
            prodi="S.Komputer";
            cout<<"Prodi anda S.Komputer"<<endl;
            tsks=sks1+sks2+sks3;
            tp=tsks*mkt2; cout<<endl;break;
        }
        default: cout<<"data yang anda input salah"<<endl;
    }

     cout<<"-------------Pembayaran SKS---------------\n";
     cout<<"Nama              : "<<nama<<endl;
     cout<<"NIM               : "<<nim<<endl;
     cout<<"Prodi             : "<<prodi<<endl;
     cout<<"Total SKS         : "<<tsks<<endl;
     cout<<"Total Pembayaran  : Rp. "<<tp<<endl;
     cout<<"-------------------------------------------\n";
}


 Pertemuan 6



 Pertemuan 7



 Pertemuan 8



 Pertemuan 9



 Pertemuan 10



 Pertemuan 11



 Pertemuan 12



 Pertemuan 13



 Pertemuan 14


















Disqus comments