Tampilkan postingan dengan label Kasus-Kasus. Tampilkan semua postingan
Tampilkan postingan dengan label Kasus-Kasus. Tampilkan semua postingan

Selasa, 17 April 2012

Fungsi Iteratif dan Rekursif

Perbedaan Fungsi Iteratif dan Fungsi Rekursif :

Bentuk fungsi Iteratif :
#include <cstdlib>
#include <iostream>
using namespace std;
int jumlah(int n) {
int hasil = 0;
for (int i=0; i<n; i=i+2)
hasil = hasil + i;
return hasil;
}
void cetak(int n) {
for (int i=0; i<n; i=i+2)
cout << i << ” “;
}
int main(int argc, char *argv[])
{
int n = 10;
cout << jumlah(n);
cetak(n);
system(“PAUSE”);
return EXIT_SUCCESS;
}
 
Bentuk fungsi rekursif :
#include <cstdlib>
#include <iostream>
using namespace std;
int jumlah(int n) {
if(n==0) return (0);
else return (n-2 + jumlah(n-2));
}
void cetak(int n) {
if(n!=0){
cetak(n-2);
cout << n-2 << ” “;
}
}
int main(int argc, char *argv[])
{
int n = 10;
cout << jumlah(n);
cetak(n);
system(“PAUSE”);
return EXIT_SUCCESS;
}
 

Program menampilkan bulan 1-12

Berikut adalah program C++nya untuk menampilkan bulan 1 sampai 12 bila kita input angkanya :

#include <iostream>
#include <string>

using namespace std;

class bulan{
      friend ostream& operator <<(ostream&,const bulan&);
      friend istream& operator >>(istream&,bulan&);
      public:
           
             bulan(unsigned int b=0){nama=b;}
            // void nama_bulan1();
             //void nama_bulan2();
             //void nama_bulan3();
             void bulannnya();
      private:
              unsigned int nama;
              };
   
      istream& operator>>(istream& masuk,bulan& x){
               cout<<"masukan angka 1 - 12 : ";
               masuk>>x.nama;
               return masuk;
               }
             
      void bulan::bulannnya(){
           switch(nama){
                         case 1 : cout<<"januari";break;
                         case 2 : cout<<"februari";break;
                         case 3 : cout<<"maret";break;
                         case 4 : cout<<"april";break;
                         case 5 : cout<<"mei";break;
                         case 6 : cout<<"juni";break;
                         case 7 : cout<<"juli";break;
                         case 8 : cout<<"agustus";break;
                         case 9 : cout<<"september";break;
                         case 10 : cout<<"oktober";break;
                         case 11 : cout<<"november";break;
                         case 12 : cout<<"desember";break;
                         default :cout<<"maaf angka yang anda masukan melebihi angka yang saya tentukan \n";
                         }
                         }
      int main(){
           bulan a;
           cin>>a;
           a.bulannnya();
           system("PAUSE");
           return 0;
           }

Menampilkan angka genap dari 25 sampai dengan 70 secara rekursif

Berikut adalah tampilan dalam bentuk C++ :

#include <iostream>
#include <string>

using namespace std;
class genap{
      friend istream& operator>>(istream&, genap&);
      friend ostream& operator<<(ostream&, genap&);
      public:
             genap();
             int proses(int i);
             private:
                     int i;
                     };
      genap::genap(){
      cout<<" menampilkan angka genap dari 25 sampai dengan 70"<<endl;
      }
     
     
      int genap::proses(int i){
          if(i>70){     
          } else
          { if(i%2==0)
          {        
          cout<<i<<endl;}
          else
          {} proses(i+1);
          }
          }
         
                            

int main()
{
    genap x;
    x.proses(25);
   
    system("PAUSE");
    return EXIT_SUCCESS;
}

Work Related Learning FUNCTION / Subprogram

The results of our second discussion:
Work Related Learning FUNCTION / Subprogram
Observations on the activity at the supermarket
As we know, the department consists of various structures that each have different functions in carrying out their duties.
In this case, we will explain in detail the activities of the existing structure and its function in the supermarket.
The observations that we get is as follows:
1) The owner opened the self-service supermarket, after all the employees get together and pray together and ensure all employees are ready with their respective duties.
2) Cleaning Service to clean all parts of the self-service and do service.
3) Then the waiter to check replenish stockpiles of goods including the goods and check out ED (Expiry Date).
4) If the goods are discharged, or ED, the waiter asked for the goods to the warehouse to replace the goods.
5) If the items in the warehouse runs out, then report to the warehouse the order.
6) Then the order will order the items out to the agent and reported to the finance section.
7) The expenditure of financial records and reported to the owner.
8.) After the goods arrived, the warehouse orders and receive goods.
9) The warehouse then check whether the goods come in accordance with the goods ordered.
10) Then turn over records of warehouse goods coming into the order.
11) The purchase order will submit a memorandum to the finance section, after the financial part will take care of the payment to the agent.
12) If all items are available, then the waiter to take the goods into the warehouse.
13) Then the waiter to add items that are less and replace items that ED (Expiry Date).
14) The buyer comes to ask for a parking ticket parking lot and parked the bike / car.
15) Then go to the supermarket buyers and selecting items to be purchased.
16) Once completed, the buyer pays to the cashier.
17) Then the cashier serving the payment of goods.
18) When finished shopping, the buyer menyerakan parkir.Lalu a parking ticket parking lot asking for money and help remove the motor / car.
19) after work up, the employees gather and report on their work - each
20) a parking lot and handed the cashier handed the money to finance income.
21) The income and expenditure of financial self-service reporting to the owner.
21) After all complete, the cleaning service to clean all parts of the supermarket.
22) The owner locked the supermarket.
Structure and Function:
>play function: Owner (Eri Pratiwi)
>call function = Finance (Fadmala Anggriana)
input: receive and record all the money goes
process: adjust expenditures for the purchase of goods and salaries
output: report income and expenses to the owner and the owner meyerahkan profit (output)
>call function = Cashier (Nurjuliansari)
input: total goods and spending money from the customer
processes: receiving goods from the customer, then add up the total price of goods, money from customers who buy goods and merekap Data penjulaan
output: give the customer purchased the goods and deposit the money into the report and the financial
>call function = Order (Ayu Laksmi Pandhita)
input: receive reports from the warehouse of goods that have been depleted
process: ordering goods out to the agent
output: receiving the goods that come with the purchase of goods warehouse and reporting
>call funtion = The warehouse (Rahmawati Surya Akmalia)
input: receive information on goods that have been depleted
process: recording of goods which have been exhausted, and then report to the order any items that have in the input, then receive the goods with the order, and then record whatever mausk goods to warehouse, control goods entering gudangmengecek whether the goods in accordance with the goods ordered
output: to report a record entry of goods into the order
>call funtion = Waiter (Intan Arista Maulydia)
input: an order from the customer (find stuff)
process: it shows the location of the items sought.
output: goods that the customer wanted.
>call funtion = Cleaning service (Sukma Aras Oyaputra)
input: given a cleaning and maintenance.
process: clean up a dirty place, mopping and sweeping floors.
output: clean and keberishan reports and maintenance of buildings.
>call funtion = Security (Pratama Siwi Handayani)
input: keep command of the leadership
process: around self-service, secure self-service, set up security at the supermarket.
output: a report to the leadership.
>new object = Buyer(customer) (Septiani Rahayu)
input: record the purchase of goods.
process: go to the supermarket and then to the area of ​​goods, and selecting items to purchase, pay for goods that have been taken to the cashier, to the park and provide a ticket.
output: the items purchased.
return of income (output)

Jumat, 13 April 2012

Untuk Mengkonversi Suhu

Berikut ini adalh Reptor untuk menampilkan konversi suhu








Langkah pertama adalh kita masukan suhunya(C).Jika kita sudah memasukan suhunya,maka akan diproses,dengan ketentuan yang ada yaitu jika
R= 4/5*C
F= 9/5*C+32
K= C+273
maka setelah itu akan keluar hasil dari konversi suhu tersebut...Keluaranya adalah sendiri-sendiri,yaitu R,F,K.

Sedangkan apabila diubah dalam bentuk C++ adalh sebagai berikut


#include <iostream>
#include <string>

using namespace std;
int main()
{
   string raptor_prompt_variable_zzyz;
   int K;
   int R;
   int C;
   int F;

   cout<<" Menampilkan hasil Konversi Suhu"<<endl;
   raptor_prompt_variable_zzyz ="masukkan besar suhu (C):";
   cout << raptor_prompt_variable_zzyz << endl;
   cin >> C;
   R =4/5*C;
   F =9/5*C+32;
   K =C+273;

   cout<<" Konversi ke Reamur         = "<<R<<endl;
   cout<<" Konversi ke Fahrenheit     = "<<F<<endl;
   cout<<" Konversi ke Kelvin         = "<<K<<endl;

   system("pause");
   return 0;
}


Minggu, 25 Maret 2012

Algoritma untuk menampilkan volume bola

Berikut ini adalah tampilan Reptor untuk menampilkan volume bola.



Jika dalam bentuk C++ beginilah gambaranya.
#include <iostream>
#include <string>

using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
int r;
int Phi;
int Volume_Bola;

Phi =3,14;
raptor_prompt_variable_zzyz ="Masukkan r :";
cout << raptor_prompt_variable_zzyz << endl;
cin >> r;
Volume_Bola =4/3*Phi*r*r*r;
cout << Volume_Bola << endl;

system("PAUSE");
return 0;
}




Menampilkan Algoritma perkalian


Flowchart untuk menampilkan bilangan fibonacci (loop)

Jumat, 23 Maret 2012

Menghitung Keliling dan Luas Lingkaran

Berikut adalah tampilan Reptor untuk menghitung keliling dan luas lungkaran


Langkah pertama adalah masukan jari-jari terlebih dahulu,
Lalu kemudian akan diproses dengan ketentuan Rumus Keliling adalah 2*3.14*r.
Sedangkan Luas lingkaran adalah 3.14*r*r.
Maka kemudian setelah diproses outputnya adalah Keliling dan Luas lingkaranya...

Menampilkan algoritma untuk menentukan hari 1-7 dalam satu minggu

Berikut ini adalah reptor untuk menampilkan hari Senin sampai Minggu dalam 1 minggu


Langkah pertama adalah kita masukan hari,misalya adalah 1(Senin),lalu akan diproses dengan ketentuan.
Bila masukan 1 maka outputnya adalah SENIN.
Bila masukan 2 maka outputnya adalah SELASA.
Begitu seterusnya sampai angka 7...yaitu MINGGU.
Jadi program tersebut akan keluar sesuai angka yang kita masukan...

Mengkonversikan nilai angka menjadi huruf

Berikut adalah tampilan Reptornya

Menentukan nilai terbesar antara tiga bilangan bulat

Berikut ini tampilan untuk menentukan nilai terbesar antara tiga bilangan bulat
Pertama adalah kita masukan nilai A,lalu B,lalu C.
Setelah itu akan diproses,maka apabila nilai A,B,C memenuhi persyaratan yaitu dengan ketentuan A>B dan A>C maka akan keluar nilai A.
Dan apabila yang dimasukan tidak sesuai ketentuan maka akan diproses kembali dengan ketentuan B>A dan B>C,maka yang keluar adalah B,dan bila salah yang keluar adalah C.









Menampilkan Rata-rata dari n bilangan bulat positif

Berikut ini adalah tampilan untuk menampilkan rata-rata dari n bilangan bulat positif




































Berikut tampilanya jika diubah ke program C++

#include <iostream>
#include <string>

using namespace std;
int main()
{
   string raptor_prompt_variable_zzyz;
   int n;
   int rata;
   int x;
   int i;
   int jumlah;

   raptor_prompt_variable_zzyz ="n =";
   cout << raptor_prompt_variable_zzyz << endl;
   cin >> n;
   jumlah =0;
   i =1;
   while (!(i>n))
   {
      raptor_prompt_variable_zzyz ="x =";
      cout << raptor_prompt_variable_zzyz << endl;
      cin >> x;
      jumlah =jumlah+x;
      i =i+1;
   }
   rata =jumlah/n;
   cout << jumlah << endl;   cout << rata << endl;
   system("pause");
   return 0;
}

Langkah2 pangambilan uang d ATM yaitu


- Masukkan kartu ATM anda
- Pilih Bahasa
- Masukkan PIN ATM anda
- Pilih menu pengambilan tunai
- Masukkan nominal yang akan di ambil
- Pilih tombol benar
- Tunggu sampai uang anda keluar 
- Setalah uang anda keluar pilih tombol selesai
- Dan ambilah kartu ATM anda

Menampilkan bilangan ganjil dari 0-10

Berikut ini adalah Reptornya untuk menampilkan bilangan ganjil anrata 0-10..
Bila kita jalankan ,maka akan keluar bilangan ganjil dari 1-10,itu dilakukan berulang-ulang sampai i nya tidak memenuhi,atau i<10..
Sedangkan jika i yang kita masukan >10,maka akan keluar langsung hasilnya...



Berikut ini apabila dari Reptor diubah menjadi C++

#include <iostream>
#include <string>
using namespace std;
int main()
{
   int i;
   i =1;
   while
(!(i>10))
   {
      if (i % 2==0)
      {
      }
      else
      {
         cout << i << endl;      }
      i =i+1;
   }
   system("pause");
   return 0;
}