import jeliot.io.*;
public class BalikAngka {
public static void balik(int n)
{
int temp = 0;
while (n>0)
{
temp = temp * 10 + n % 10;
if (temp == 0)
{
System.out.print("0");
}
n = n/10;
}
System.out.print(temp);
}
public static void main()
{
int bil;
System.out.print("Masukkan bilangan : ");
bil = Input.readInt();
System.out.print("Setelah dibalik : ");
balik(bil);
}
}
Rabu, 20 April 2011
Minggu, 10 April 2011
POM BENSIN
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <math.h>
#include <iomanip>
using namespace std;
class SPBU{
private:
float rp;
float ltr;
int jum;
float litlit;
int jum1;
float bensin,bensin2,bensin3,bensin4;
#include <iostream>
#include <time.h>
#include <math.h>
#include <iomanip>
using namespace std;
class SPBU{
private:
float rp;
float ltr;
int jum;
float litlit;
int jum1;
float bensin,bensin2,bensin3,bensin4;
public:
float menu();
float liter();
void rupiah();
double ulang();
void wait (float seconds);
};
float SPBU::menu(){
char pil;
cout<<”\b”;
float menu();
float liter();
void rupiah();
double ulang();
void wait (float seconds);
};
float SPBU::menu(){
char pil;
cout<<”\b”;
cout<<”\a\t\t+\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\5\5\5\5\5\5\5+\n”;
cout<<”\t\t\3 \3\n”;
cout<<”\t\t\3 SELAMAT DATANG DI POM BENSIN PASTI PAS BANGET \3\n”;
cout<<”\t\t\3 \3\n”;
cout<<”\t\t+\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\5\5\5\5\5\5\5\5+\n”;
cout << “\t\t +———————————–+” << endl;
cout << “\t\t | MENU |” << endl;
cout << “\t\t +———————————–+” << endl << endl;
cout<<”\t\t\t\tSilahkan Pilih: \n”;
cout<<”\t\t\t\t1. Rupiah”<<endl;
cout<<”\t\t\t\t2. Liter”<<endl;
cout<<”\t\t\t\t3. Exit”<<endl;
cout<<”\t\t\t\t==================”<<endl;
cout<<”\t\t\t\tMasukkan Pilihan: “;cin>>pil;
pil=toupper(pil);
while(!((pil==’1′)||(pil==’2′)||(pil==’3′))){
cout<<”Pilian SALAH\nPilihan diluar jangkauan..!\nPilih nomor 1-3\n”;
cout<<”Pilih salah satu:”;cin>>pil;
pil=toupper(pil);
}
switch(pil){
case ’1′: rupiah(); break;
case ’2′: liter(); break;
case ’3′: cout<<”Terima Kasih\n”; system(“exit”); break;
default: cout<<”Terimakasih”<<endl;
}
}
cout<<”\t\t\3 \3\n”;
cout<<”\t\t\3 SELAMAT DATANG DI POM BENSIN PASTI PAS BANGET \3\n”;
cout<<”\t\t\3 \3\n”;
cout<<”\t\t+\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\5\5\5\5\5\5\5\5+\n”;
cout << “\t\t +———————————–+” << endl;
cout << “\t\t | MENU |” << endl;
cout << “\t\t +———————————–+” << endl << endl;
cout<<”\t\t\t\tSilahkan Pilih: \n”;
cout<<”\t\t\t\t1. Rupiah”<<endl;
cout<<”\t\t\t\t2. Liter”<<endl;
cout<<”\t\t\t\t3. Exit”<<endl;
cout<<”\t\t\t\t==================”<<endl;
cout<<”\t\t\t\tMasukkan Pilihan: “;cin>>pil;
pil=toupper(pil);
while(!((pil==’1′)||(pil==’2′)||(pil==’3′))){
cout<<”Pilian SALAH\nPilihan diluar jangkauan..!\nPilih nomor 1-3\n”;
cout<<”Pilih salah satu:”;cin>>pil;
pil=toupper(pil);
}
switch(pil){
case ’1′: rupiah(); break;
case ’2′: liter(); break;
case ’3′: cout<<”Terima Kasih\n”; system(“exit”); break;
default: cout<<”Terimakasih”<<endl;
}
}
luas lingkaran dan volume
#include <cstdlib>
#include <iostream>
#define pi 3.14
#include <math.h>
#include <iostream>
#define pi 3.14
#include <math.h>
using namespace std;
class hitung{
friend ostream& operator<<(ostream&, const hitung&);
friend istream& operator>>(istream&, hitung&);
public:class hitung{
friend ostream& operator<<(ostream&, const hitung&);
friend istream& operator>>(istream&, hitung&);
hitung();
void luaslingkaran(){luas=pi*r*r;}
void volumebola(){volume=((pi*r*r*r)/3);}
private:
int r;
float luas;
float volume;
};
jarak 2 titik in c++
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <conio.h>
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
class jarak {
public :
void baca1();
void baca2();
void tulis1();
private :class jarak {
public :
void baca1();
void baca2();
void tulis1();
double a1,a2,a3,a4;
};
void jarak::baca1 (){
cout<<”Masukkan X1 :”;cin>>a1;
cout<<”Masukkan Y1 :”;cin>>a2;
cout<<”Masukkan X2 :”;cin>>a3;
cout<<”Masukkan Y2 :”;cin>>a4;
cout<<endl;
}
#include <cstdlib>
#include <iostream>
using namespace std;
class kfb {
public:
void data();
void rumus1();
void cetak();
private:
int i,kpk;
int m,n,r;
};
void kfb::data(){
cout << "Masukkan nilai A : ";
cin >> m;
cout << "Masukkan nilai B : " ;
cin >> n;
}
void kfb::rumus1(){
r = m%n;
while (r!=0)
{
m = n;
n = r;
r = m%n;
}
}
void kfb::cetak(){
cout <<"FPB A dan B adalah : "<<n<<endl;
}
int main(int argc, char *argv[])
{
kfb a;
a.data();
a.rumus1();
cout<<endl;
a.cetak();
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
using namespace std;
class kfb {
public:
void data();
void rumus1();
void cetak();
private:
int i,kpk;
int m,n,r;
};
void kfb::data(){
cout << "Masukkan nilai A : ";
cin >> m;
cout << "Masukkan nilai B : " ;
cin >> n;
}
void kfb::rumus1(){
r = m%n;
while (r!=0)
{
m = n;
n = r;
r = m%n;
}
}
void kfb::cetak(){
cout <<"FPB A dan B adalah : "<<n<<endl;
}
int main(int argc, char *argv[])
{
kfb a;
a.data();
a.rumus1();
cout<<endl;
a.cetak();
system("PAUSE");
return EXIT_SUCCESS;
}
Rabu, 23 Maret 2011
| Program Mencari Total Dari 1-n #include <iostream.h> |
| #include <conio.h> |
| class total |
| { |
| friend istream & operator >> ( istream &, total& ); |
| friend ostream & operator<< ( ostream &, total& ); |
| public: |
| total(); |
| void tambah(){jumlah = 0; |
| for (i = 1; i<=n; i++) |
| jumlah += i; |
| } |
| private: |
| int n,i,jumlah; |
| }; |
| total::total() |
| {cout<<"PROGRAM MENCARI TOTAL DARI 1 - N"<<endl; |
| }; |
| istream & operator >> ( istream & in, total & msuk ) |
| { |
| cout << "masukkan bilangan : " ; |
| in >> msuk.n; |
| return in; |
| } |
| ostream & operator<< ( ostream &out, total& keluar) |
| { |
| out<<"hasilnya totalnya = "<<keluar.jumlah<<endl; |
| return out; |
| } |
| main() |
| { |
| total hu; |
| cin >> hu; |
| hu.tambah(); |
| cout<<hu; |
| getch(); |
| return 0; |
| } |
Langganan:
Postingan (Atom)