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;

}