Minggu, 28 April 2013

menghitung luas dan keliling elip program java


penulis menjelaskan bagai mana cara menghitung luas dan keliling elip program java
berikut sourcodenya


import java.util.Scanner;
class Elips{
double phi = 3.14;
double Panjang;
double Lebar;

public Elips(double p, double l){
this.Panjang = p;
this.Lebar = l;
}
}

class Elips1 extends Elips{
public Elips1(double p, double l){
super(p,l);
}
public double getLuas(){
return (0.5*phi*Panjang*Lebar);
}
public double getKeliling(){
return (0.5*phi*(Panjang+Lebar));
}
}
class cetak{
public static void main(String[] args){
Scanner sc = new Scanner (System.in);
System.out.print("Sumbu Panjang: ");
double p = sc.nextDouble();
System.out.print("Sumbu Lebar: ");
double l = sc.nextDouble();
Elips1 elp1 = new Elips1 (p,l);
System.out.println("Keliling elips: "+elp1.getKeliling());
System.out.println("Luas Elips: "+elp1.getLuas());
}
}


fibonancy for java


fibonancy for java

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

void main ()
{
clrscr();
int  jum, tot, bil, x, i, m, tahun;
cout << " masukkan batas deret : " ;
cin >> bil ;
cout << " deret ke = ";
cin >> m;
cout << " tahun kelahiran = ";
cin >> tahun;
cout << "tampilan deret : ";

jum = 1 ;
x = 1 ;
tot = 0;
for (i=1; i<= bil; i++) {
if ( i%m ){
i = tahun ;
cout << " " << i;
}
tot = tot + jum;
cout << " " << jum ;
jum = jum + bil ;
x=jum-x;


}
cout << " jumlah : " << tot << endl;
}

faktorisasi prima C++

faktorisasi prima C++


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

void main()
{
clrscr();
int bil, I, J;
cout << "input bilangan = ";
cin >> bil;
for (I=2; I<=bil; I++)
{
if (bil%I==0)
{
if (I==2)
{
cout << I << "  ";
}
else
{
for (J=2; J<=I-1; J++)
{
if (I%J==0)
{
goto selesai;
}
}
cout << I << "  ";
}
selesai:
}
}
}

celcius,farenheit,reamur,kelvin


share dikit bagi pemula yang mempelajari C++
ini sourcode program c yang menghitung suhu



#include<iostream.h>
void main()
{
float C, F ,R,K;
cout<<"masukkan nilai Celcius = "<<endl;
cin>>C;
F = (C * 1.8) + 32;
cout<<"nilai Fahrenheit = "<<F<<endl;
R = C * 0.8;
cout<<"nilai Reamur = "<<R<<endl;
K = C + 273.15;
cout<<"nilai Kelvin = "<<K<<endl;
}