Sunday, 3 November 2024

Contoh Program Perulangan

 #include <iostream>

using namespace std;

int main()

{

int pilihan;

cout<<" Jenis Pilihan 1: 2: 3: 4:"<<endl;

atas:

cout<<" Menu Pilihan : ";cin>>pilihan;

if(pilihan==1)

{

  cout << "##  Program C++ Persegi Bintang  ##" << endl;

  cout << "===================================" << endl;

  cout << endl;

  int besar_persegi,i,j;

  cout << "Input besar persegi: ";

  cin >> besar_persegi;

 

Sunday, 13 October 2024

Program Kasir Sederhana sekali

 #include <iostream>

using namespace std;

int main()

{

    int bayar,akhir,diskon,uang;

    cout<<"Contoh Program c++ Diskon"<<" Kasir Serba Ajaib"<<endl;

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

    cout<<"Total pembayaran : ";

    cin>>bayar;

    if ((bayar>=100000) && (bayar<500000)){

        diskon=bayar*0.10;

        akhir=bayar-diskon;

        cout<<endl<<"selamat anda mendapatkan diskon 10%"<<endl;

Program Login

#include<iostream>

#include<stdlib.h>

using namespace std;

int main() {    

   int i;  

   string pass_input, user_input;  

   

   cout << "==========================================" <<endl;    

   cout << "          P R O G R A M L O G I N         " <<endl;    

   cout << "==========================================" <<endl;  

   cout << "Silahkan Login jika ingin mengetahui nya.." <<endl;  

   cout << "==========================================" <<endl;

   string username ="admin";    

   string password = "admin666";    

   string login = "invalid";    

   i = 1;    

   

Monday, 7 October 2024

Program Tahun Kabisat

 #include <iostream>

using namespace std;

int main()

{

  cout << "##  Program C++ Cek Tahun Kabisat  ##" << endl;

  cout << "=====================================" << endl;

  cout << endl;

  int year;

  string ket;

  cout << "Input tahun: "; cin >> year;

 

   if (year % 400 == 0) {

     ket=" adalah tahun kabisat";

   }

   else if (year % 100 == 0) {

     ket=" bukan tahun kabisat";

   }

Sunday, 6 October 2024

Program Belanja

 #include <iostream>

using namespace std;

int main()

{

  cout << "**  Program Belanja C++   **" << endl;

  cout << "=========================================" << endl;

  cout << endl;

  int total_belanja, harga_akhir, jumlah_barang, harga_barang;

 string nama_barang;

 

Program Menghitung Gaji Pegawai

 #include <iostream>

using namespace std;

int main()

{

 cout << "**  Program Menghitung Gaji Pegawai   **" << endl;

 cout << "========================================" << endl;

 cout << endl;

 string nama;

 char golongan;

 int jam_kerja, upah_per_jam, total_upah;

 

 // proses input data

 cout << "Nama Karyawan: "; getline(cin,nama);

 cout << "Golongan: "; cin >> golongan;

 cout << "Jumlah jam kerja: ";cin >> jam_kerja;

 // tentukan kondisi jumlah upah per jam berdasarkan golongan

Thursday, 11 July 2024

Program Perbaikan UAS 2

 #include <iostream>

#include <string>

#include <iomanip>

#include <cmath>

using namespace std;


bool cekPrima(int num) {

    if (num <= 1) return false;

    for (int i = 2; i <= sqrt(num); i++) {

        if (num % i == 0) return false;

    }

    return true;

}

Program Perbaikan UAS 1

 #include <iostream>

#include <iomanip>

#include <string>

using namespace std;


struct Barang {

    string nama;

    double harga;

    int jumlah;

};


struct Pelanggan {

    string NIK;

    string nama;

    string alamat;

    int umur;

    long pembelian;

};


int main() {

    string password = "password";


    string inputPassword;


    bool passwordBenar = false;

Thursday, 20 June 2024

Program karyawan

 struct karyawan {

    string nama;

    char golongan;

    int jumlah_anak;

    int gapok;

    int JA;

    int Ttl_Gaji;

    int Ttl_jmlank;

};


int main() {

    int n;

    cout << "Masukan Jumlah Karyawan : ";

    cin >> n;

Program Belanja

 #include <conio.h>

#include <stdio.h>

#include <iostream>

#include <iomanip>

#include <fstream>

#include <cmath>

using namespace std;


int main( )

{

   struct program{

    int hb;

Program Mahasiswa

 #include <conio.h>

#include <stdio.h>

#include <iostream>

#include <iomanip>

#include <fstream>

#include <cmath>

#include <string>

#include<windows.h>

using namespace std;


int main()

{

Sunday, 21 April 2024

Buble Sort

 #include<iostream>

using namespace std;

int main()

{

int temp;

//int x[]={10,5,2,7,8,3};

int x[]={17,23,12,00,49};

int j = sizeof(x)/sizeof(*x);

cout<<" X : ";

for(int i=0; i<j; i++)

{

cout<<x[i]<<" ";

}

Selection Sort

 #include<iostream>

using namespace std;


int main()

{

int x[]={3,4,6,5,2};

int j = sizeof(x)/sizeof(*x);

int temp,pos,y;

cout<<" y : ";

for(int i=0; i<j;i++){

cout<<x[i]<<" ";

}

cout<<endl;

//pengurutan selection

for(int a=0; a<j;a++){

temp=x[a];

pos=a;

for(int b=a;b<j;b++){

if(x[b]<temp){

temp=x[b];

pos = b;

}

Monday, 1 April 2024

Program C++ Bentuk Love

#include <iostream>

#include <conio.h>

using namespace std;

int main(){

int i,j;

for(i=1;i<=22;i++)

{

         for(j=1;j<=60;j++){

Program Menu Pilihan

#include <iostream>

#include <conio.h>

#include <stdlib.h>

using namespace std;

/**-------------------------

 Algoritma dan Pemrograman

 ---------------------------**/

int main() {

    unsigned int pilihan;

    cout << "MENU PILIHAN" << endl;

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

    cout << "1. hitung luas lingkaran" << endl;

    cout << "2. hitung luas persegi" << endl;

    cout << "3. hitung luas segitiga" << endl;

    cout << "4. exit" << endl;

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

   while (pilihan>=0){

    cout << "pilihan anda (1/2/3/4)         : "; cin >> pilihan;

     if (pilihan== 1) 

{