Rabu, 13 April 2011

menentukan tahun kabisat menggunakan JELIOT


public class tahun_kabisat{
int x;
public int bil(int x){
return x;
}
public final void kabisat()
{
int bil;
bil=Input.readInt();
if(bil % 4 == 0)
{
System.out.print("Tahun kabisat.\n");
}
else
{
System.out.print("Tahun bukan kabisat.\n");
}

System.out.print(bil);

}
public tahun_kabisat()
{
System.out.print("Program untuk menampilkan tahun kabisat");
System.out.print("\n");
}
}
public class MyClass {
public static void main() {
tahun_kabisat x = new tahun_kabisat();
x.kabisat();
System.out.print("\n");
}
}

menentukan tahun kabisat menggunakan dev c++


#include
#include

using namespace std;
class tahun_kabisat{
friend istream& operator>>(istream&,tahun_kabisat&);
private:
int bil;

public:
void kabisat();
};
istream& operator>>(istream& in,tahun_kabisat& x) {
cout<<"Masukkan tahun="; in>>x.bil;
return in;
}

void tahun_kabisat :: kabisat(){
if(bil % 4 == 0){
cout<<"Tahun kabisat.\n"; } else cout<<"Bukan tahun kabisat.\n"; cout<>X;
X.kabisat();

cout<

system("PAUSE");
return EXIT_SUCCESS;
}

mencari volume bola & luas lingkaran


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

using namespace std;

class hitung{
      friend ostream& operator<<(ostream&, const hitung&);
      friend istream& operator>>(istream&, hitung&);

public:
    
        void hitung_L_lingkaran();
        void hitung_V_bola();

        private:
                float r;
                float Phi;
                float luas;
                float volume;
                };


void hitung::hitung_L_lingkaran(){
    Phi=3.14;
    luas=Phi*r*r;
     }

void hitung::hitung_V_bola(){
          volume=1.33*3.14*r*r*r;
          }

istream& operator>>(istream& in, hitung& masukan){
                   
                   cout<<"Menghitung luas lingkaran.\n""\n";
                   cout<<"Masukan jari-jarinya lingkaran:";
                   in>>masukan.r;
                   cout<<"Menhitung volume bola.\n""\n";
                   cout<<"Masukan jari jari bola:";
                   in>>masukan.r;
                   return in;
                   }

ostream& operator<<(ostream& out, const hitung& keluaran){
                            out<<"jari-jari lingkaran:"<<keluaran.r<<endl;
                            out<<"jari-jari bola:"<<keluaran.r<<endl;                      
                            out<<"luas lingkaran:"<<keluaran.luas<<endl;
                            out<<"volume bola:"<<keluaran.volume<<endl;
                            return out;

mencari volume bola & luas lingkaran menggunakan JELIO

import jeliot.io.*;

public class MyClass {
    public static void main() {
        // Your algorithm goes here.

int r;
float volume;
System.out.print("masukan r = ");
r = Input.readInt();
volume= (float)((3.14*r*r*r*3)/4);
luas_lingkaran=(float)(3.14*r*r);
   System.out.print(volume);
}
}

mencari nilai KPK menggunakan Dev C++

#include <cstdlib>
#include <iostream>
                
using namespace std;

class kpk
{

public:
    void input();
   void output();
   void proses();

private:
    int a,b,c;
   int nilai;
};

  void kpk::input(){
    cout<<"Masukkan Nilai Bil A : "; cin>>a;
    cout<<"Masukkan Nilai Bil B : "; cin>>b;
   

  }
void kpk::proses(){
    
     int fpb;
     fpb = a%b;
     nilai = (a*b)/abs(fpb);
    
}

void kpk::output()
{
     proses();
    cout<<"KPK Antara "<<a<<" dan "<<b<<" Adalah "<<nilai<<endl;
   
}




int main(int argc, char *argv[])
{
   
    kpk bilangan;
   bilangan.input();
   bilangan.output();
    system("PAUSE");
    return EXIT_SUCCESS;
}

Fungsi untuk menghitung jarak 2 titik


#include <iostream.h>

  class JARAK {
     private:
      float x1, x2, y1, y2;
      double hasil, a, b;
     public:
       void titik(){
         cout<<"masukkan nilai x1 :";
         cin>>x1;
         cout<<"masukkan nilai x2 :";
         cin>>x2;
         cout<<"masukkan nilai y1 :";
         cin>>y1;
         cout<<"masukkan nilai y2 :";
         cin>>y2;

         a = (x1-x2) * (x1-x2);
         b = (y1-y2) * (y1-y2);
         hasil = a + b;
         cout<<"hasil jarak dari 2 titik adalah :"<<hasil<<endl;
       }
     };
int main(){
    int x;
     JARAK J;
     J.titik();
    cin>>x;

        return 0;
}

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Blogger Theme by Lasantha - Premium Blogger Templates | Affiliate Network Reviews