You are viewing genduts_club

genduts_club
26 December 2007 @ 11:46 am
Berikut adalah project kelas c++ saya.

Nantikan kelanjutannya !!


Project Elevator
A company inteds to build a two story office building and wquip it with the ";atest" elebator technology. The company  wants you to develop an object-oriented software simulator that models the operation of the elevator to determine if this elevator will meet their needs.

The elevator, which has a capacity of onw person is designed to conserve energy, so it only moves when necessary. The elevator stats the day waiting with its door shut of floor 1 of the building. The elevaotr, of course, alternates directions--first up, then down.

Your simulator includes a clock that begins the day set to time 0 and that "ticks" once per second. The "scheduler" componen of the simulaotr randomly schedules the arrival of the first person on each floor (you will learn how to schdedule random arrivals in Chapter 3). When the clock's time becomes equal to the time of the first arrival, the simulator "creates" a new person for the specified floor, and place the person on that floor. The pesrson then presses the button on that floor to summon the elevator. The person's destination floor is never equal to the floor on which that person arrives.

If the first person of the day arrives at floor 1, the person can immediately get ont the elevator (after pressing the button and waiting for the elevator's door to open, of course!). If the first person arrives at floor 2, the elevator proceeds to floor 2 to pick up that person. The elevaotr requires five tics of the clock tor travel between floors.

The elevator signal its arrival at a floor by turning on a light above the elevator door on that floor and by sounding a bell insed the elevator. The button on the floor and  the button in the elevator for that floor are reset, the elevator opens its door, the passenger--if there is on whose destination is that floor--gets out of the elevator, another passenger--if there is one waiting on that floor--gets into the elevator and presses a destination button, and the elevator closes its door. If the elevator needs to begin moving, it determines in which direction it should go (a simple decision on a two-story elevator!), and begins moving to the next floor. For simplicity, assume that all of the events that happen once the elevator reaches a floor, an until the elevator closes its doors on that floor, take zero time . The elevator always knows what floor it is on and what floor it is going to.

At most one person can be waiting on each floor at any time, so if a floor is occupied when a new person (i.e., not a person already on the elevator) is due to arrive at that floor, the new arrival is rescheduled for one second later. Assume that people arrive at random on each floor every 5 to 20 seconds--in Chapter 3 you will learn how to use random number generation to simulate this arrival rate.

Your goal (over these special section in Chapter 2 through 8) is to implement a working software simulator program that runs accourding to these specifications. Your program should simulate several minutes of the elevator's operation and determine if the elevator will successfully meet the anticipated traffic requirements in this office building.
 
 
Current Location: Get On Line warnet
Current Mood: anxiousanxious
Current Music: Shizuku - Okuda Miwako
 
 
genduts_club
26 December 2007 @ 11:27 am
// Berikut adalah program sederhan melakukan pelemparan dadu secara sederhana
// Dadu dilakukan dengan pelemparan random dengan seed berdasarkan waktu saat dijalankannya program
// Program ini diambil dari contoh program kursus C++ saya.

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <time.h>

int main()
{
   const int arraySize = 7;
   int face, frequency[ arraySize ] = { 0 };

   srand( time( 0 ) );

   for ( int roll = 1; roll <= 6000; roll++ )       
      ++frequency[ 1 + rand() % 6 ];
                                    
   cout << "Face" << setw( 13 ) << "Frequency" << endl;

   // ignore element 0 in the frequency array
   for ( face = 1; face < arraySize ; face++ )  
      cout << setw( 4 ) << face
           << setw( 13 ) << frequency[ face ] << endl;

   return 0;
}
 
 
Current Location: Get On Line warnet
Current Mood: awake
Current Music: Fly me to the moon
 
 
genduts_club
26 December 2007 @ 11:05 am
// Berikut adalah contoh sederhana cara untuk melakukan rata-rata sebuah kelas.

#include <iostream.h>
#include <iomanip.h>

int main()
{
   int total,                  
        penanda,  
        nilai;                 
   float rata2;        

   total = 0;
   penanda = 0;

   // processing phase
   cout << "Masukkan nilai , -1 untuk berhenti: ";    
   cin >> nilai;                         

   while ( nilai != -1 ) {                  
      total = total + nilai;              
      penanda = penanda + 1;              
      cout << "Masukkan nilai, -1 untuk berhenti ";
      cin >> nilai;                       
   }

 if ( gradeCounter != 0 ) {     
      rata2 = static_cast< float >( total ) / penanda;   
      cout << "Class average is " << setprecision( 2 )
           << setiosflags( ios::fixed | ios::showpoint )
           << rata2 << endl;
   }
   else
      cout << "Masukan dong nilainya!" << endl;

   return 0;  
}
 
 
Current Location: Get On Line warnet
Current Mood: artistic
Current Music: Get it all right
 
 
genduts_club
12 December 2007 @ 05:52 am
This is one aspect on my final exam in university optimizing a portfolio.
How can you make the best benefit form a portfolio based on previous gain / loss history.  On my there are several method to optimize the portfolio gain. But there is one that easy and reliable to use with small data range.

i'll give the explanation and the code next week as well my other side project.

regards, heidy
 
 
Current Location: warnet
Current Mood: excitedexcited
Current Music: T2 - Lelaki Cadangan
 
 
genduts_club
12 December 2007 @ 04:19 am
This is my preview on home made traction control. It suppose tobe a simple programming using 2 stream of data. The the tire and vehicle speed and CDI for controlling the traction.

The definition about traction control can be seen on http;//www.securitydriver.com/aic/stories/article-111.html. On the article there are two ways traction control operates.
    1. traction control use brakes to slow the car
    2. reducing engine power

I choose CDI to control the traction for several reason
    1. it's not intefering much of the vehicles physics
    2. safer for some reason
    3. it's the sistem use by F1 car

There are some assumption on making this Homemade Traction Control. I am assure you that some is usefull some make no sense. Afterall i'm just an economic graduate that have passion on automotive and computer.

Engine                 M111 (1799 cc) Front Engine Rear Wheel Drive
Output                  90KW or  120 Hp / 6200 rpm
Torsi                     170Nm pada 4200 rpm

Dimension
Length                  4487 mm
Width                     1720 mm
Height                   1414 mm
Axle Length          1395 mm

Weight
Empty                    1350 Kg
Maximum Cap.    1830 Kg

Weight Distribution
46%           :            54%
front                      rear


The very basic physics
1. loss of grip or skid can happen when the tyre lost the grip with the tarmac
2. this can happen when the amount for force given to the wheel is exceeding its grip to tarmac
3. skid can happen on a slippery surface like on wet or icy road
4. the velocity of the wheel and tire is different
5. when skid the rotation on left and right side different (especially when turning)
 
 
Current Location: jakarta
Current Mood: haven't sleep allnight
Current Music: chase - Chase me!
 
 
genduts_club
12 December 2007 @ 01:56 am
A reverse string code

This reverse code is similar the code that i write on a job application test for a junior programmer. It's a simple code to reverse the string. This version is still have an error but i can't find it. Please give your comment.

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

#define MAX 13

main()
{
    int i = MAX;
    char input_string[i];


    cout << "Selamat Datang di Program Pembalik String \n";
    clrscr();
    cout << "Masukkan sebuah string (maksimal 13 karakter) \n";
    cin >> input_string[i];
    /*if(sizeof(input_string[i])) >> sizeof(int * 13))
        {
          cout << "karakter terlalu banyak! bye";
          exit(1);
        }
    */
    cout << "Hasil pembalikkan string adalah \n";
    for(i = 13; i >0; i--)
        {
           do
             {
                cout << input_string[i];
                if(input_string[i] == '\n')
               {
                    i = 13;
               }
               }
          while (input_string[i] != '\0');
    }
    return 0;
}

 
 
genduts_club
12 December 2007 @ 01:52 am
This is my revision on simple pass code

The revision made on this code is minimal due to no compiler on the computer when i post that entry. Now the error is minimum.

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

main()
{
    static char nama[10], pass[10];
    char temp[10];

    clrscr();
    printf("Nama yang diinginkan: (maksimal 10 character) \n");
    scanf(nama);
    printf("Password yang diingikan: (maksimal 10 character) \n");
    scanf(pass);

    clrscr();
    printf("\t\t Selamat datang di program password ver.1 Genduts_Club\n");
    printf("\t\t Nama : ");
    scanf(temp);
    if((temp) != nama)
       {
            printf("No such name found!");
            exit (1);
        }

    printf("\t\t Password: ");
    scanf(temp);
    if((temp) != nama)
       {
            printf("Wrong password!");
            exit (1);
        }

   clrscr();
    printf("Hello %s, how are you today!");


    return (0);
}
 
 
genduts_club
12 December 2007 @ 01:08 am
Revision on linkedlist

This is my revision on the linked list. I have minimized the error. Hopefully the next version i use class instead of struct.

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

struct biodata
    {
        char firstname;
        char lastname;
        char address;
        struct biodata *next_one;
    }data_karyawan, *first_one, *current_one;

void location(struct biodata *posisi);
void data_out(struct biodata *ptr_data);
int data_in(struct biodata *data_karyawan);

main ()
{
    first_one = (struct biodata *) new (struct biodata);
    if (first_one == 0) exit (1);
    if (data_in (&data_karyawan) != 0) exit (1);
    *first_one = data_karyawan;
    current_one = first_one;

    while (data_in(&data_karyawan) == 0)
        {
           current_one->next_one = (struct biodata *) new (struct biodata);
           if (current_one->next_one == 0) exit (1);
           current_one = current_one->next_one;
           *current_one = data_karyawan;
        }
    current_one->next_one = 0;
    location(first_one);
    return 0;
}

void location(struct biodata *posisi)
    {
        do
            {
               data_out(posisi);
            } while ((posisi = posisi->next_one) != 0);
    }

void data_out(struct biodata *ptr_data)
    {
        cout << "Seorang karyawan adalah" << ptr_data->firstname <<  "Nama lengkapnya adalah" << ptr_data->firstname << endl;
        cout << "Karyawan ini bertempat tinggal di" << ptr_data->address << endl;
    }

int data_in(struct biodata *data_karyawan)
    {
        cout << "Masukkan informasi berikut \n";
        cout << "Masukkan nama awal: (Q untuk berhenti)";
        cin >> data_karyawan->firstname;
        if ((data_karyawan->firstname) == 'Q')
            return (1);
        cout << "\n Masukkan nama keluarga: ";
        cin >> data_karyawan->lastname;
        cout << "\n Masukkan alamat karyawan";
        cin >> data_karyawan->address;
        return (0);
    }
 
 
Current Location: Depok
Current Mood: cheerfulI'm happy
Current Music: no music
 
 
genduts_club
30 November 2007 @ 05:29 am
Simple Linked List
Simple linked list adalah bagaimana sebuah program menggunakan structure/class dimana member dari structure tersebut terdapat sebuah pointer mengarahkan ke structure selanjutnya. Simple linked list merupakan salah nenek moyang dari object oriented programming. Show some respect to this one. Pada contoh pemromgraman ini saya menggunakan struct yang diinspirasikan dari buku Turbo C++ Professional Handbook Chris H Pappas hal 423.  Nantikan versi kedua dimana saya menggunakan class bukan lagi structure.

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

struct biodata{
    char firstname;
    char lastname;
    char address;
    struct biodata *next_one;  
}data_karyawan, *first_one, *current_one;

void location(struct biodata *posisi);
void data_out(struct biodata *ptr_data);
int data_in(struct biodata *data_karyawan);

main (){
    first_one = (struct biodata *) new (struct biodata);
    if (first_one == 0) exit (1);
    if (data_in (&data_karyawan) != 0) exit (1);
    *first_one = data_karyawan;
    current_one = first_one;

    while (data_in(&data_karyawan) == 0){
       current_one->next_one = (struct biodata *) new (struct biodata);
       if (current_one->next_one == 0) exit (1);
       current_one = current_one->next_one;
       *current_one = data_karyawan;       
    }
    current_one->next_one = 0;
    location(first_one);
    return 0;
}

void location(struct biodata *posisi){
    do{
       data_out(posisi);
    } while ((posisi = posisi->next_one) != 0);
}

void data_out(struct biodata *ptr_data){
    cout << "Seorang karyawan adalah" << ptr_data->firstname <<  "Nama lengkapnya adalah" << ptr_data->firstname << endl;
    cout << "Karyawan ini bertempat tinggal di" << ptr_data->address << endl;
}

int data_in(struct car *data_karyawan){
    cout << "Masukkan informasi berikut \n";
    cout << "Masukkan nama awal: (Q untuk berhenti);
    cin >> data_karyawan->firstname;
    if (*(data_karyawan->firstname) == 'Q')
       return (1);
    cout << "\n Masukkan nama keluarga: ";
    cin >> data_karyawan->lastname;
    cout << "\n Masukkan alamat karyawan";
    cin >> data_karyawan->address;
    return (0);
}
 
 
Current Location: Jakarta
Current Mood: accomplished
Current Music: Endless Rain - X Japan
 
 
genduts_club
30 November 2007 @ 03:47 am
Membalikkan string

Berikut adalah contoh hasil program test untuk sebuah perusahaan it yang bergerak dibidang voice management. Programnya adalah bagaimana cara untuk membalikkan string yang telah dimasukkan user.

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

#define MAXSTRING 13

main(){
    char input_string[i];
    int i = MAXSTRING;
    int max;
   
    cout << "Selamat Datang di Program Pembalik String \n";
    clrscr();
    cout << "Masukkan sebuah string (maksimal 13 karakter) \n"l;
    cin >> input_string[MAXSTRING];
    if(sizeof input_string[MAXSTRING] > 13*int){
       cout << "karakter terlalu banyak! bye";
       exit (1);
    }
   
    cout << "Hasil pembalikkan string adalah \n";
    for(i = 13; i >0; i--){
       do{
            cout << input_string[i];
            if(input_string[i] == '\n'){
                i =max;
           }
       }
       while (input_string[i] != '\0'
    }
    return 0;
}
 
 
Current Location: Jakarta
Current Mood: annoyedannoyed
Current Music: OK - T2