counters
Tampilkan postingan dengan label raptor. Tampilkan semua postingan
Tampilkan postingan dengan label raptor. Tampilkan semua postingan

Rabu, 25 Maret 2015

TUGAS MENTOR FAKTORIAL DALAM TIGA VERSI

a. faktorial dalam versi raptor


b. faktorial dalam versi dev c++

#include <iostream>

/* run this  using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;
class faktor {
int n;
int total;
public :
faktor();
void input();
void proses();
void output();
};
faktor::faktor(){
cout <<"program faktorial"<<endl;
}
void faktor::input(){
cout<<"masukkan nilai fakorial"<<endl;
}
void faktor::proses(){
total = 1;
cout<<n<<"! = ";
for(int i=n;i>0;i--){
total = total*i;
cout<<i;
if(i!=1){
cout<<"x";
}
}
}
void faktor::output(){
cout<<endl<<"hasil : "<<total;
}

int main(int argc, char *argv[]) {
faktor hasil;
hasil.input();
hasil.proses();
hasil.output();
return 0;
}

c. fatorial dalam versi jeliot

import jeliot.io.*;
class faktor{
int i;
int n;
int total;
void input(){
n = Input.readInt();
}
void proses(){
total =1;

for (i=n;i>0;i--)
{
  total = total*i;
  
  }
 }
 void output(){
 output.printIn("Hasil = " + total);
 }
 };

public class MyClass {
    public static void main() {
    faktor hasil = new faktor();
    hasil.input();
    hasil.proses();
    hasil.output();
        
        

    }
}