Di delok wae nek pengen di download yo ora opo-opo, nek pengen di delok tok yo ora opo - opo sink penting kabeh do suka-suka.... Asykwae...
public class PiramidaBilanganTerbalik{
public static void main(String[] args){
for (int a = 5; a >= 1; a--){
for (int b = 1; b <= 5-a; b++)
System.out.print(" ");
for (int c = a; c >= 1; c--)
System.out.print(c);
for (int c = 2; c <= a; c++)
System.out.print(c);
System.out.println();
}
}
}
Gambar : Hasil Class
asykwae toh...
public class PiramidaBilangan{
public static void main(String[] args){
for (int a = 1; a <= 5; a++){
for (int b = 1; b <= 5-a; b++)
System.out.print(" ");
for (int c = a; c >= 1; c--)
System.out.print(c);
for (int c = 2; c <= a; c++)
System.out.print(c);
System.out.println();
}
}
}
Gambar : Hasil Class
Enjoy aja....
ojok cuman di delok lho yo...
tapi dipelajari pisan...
Asykwae...
Ndelokwae...
Pada kasus berikut, untuk bilangan Ganjil tetap...
sedangkan untuk bilangan Genap dikalikan 2 (dua)...
contoh :
1
2 x 2 = 4
3
4 x 2 = 8
5
6 x 2 = 12
dst...
--------------------
contoh class :
-----------------------
public class KaliGanjil{
public static void main(String args[]){
for(int i = 1; i<=10; i++){
if (i % 2 == 1){
System.out.println(i + " ");
}else{
System.out.println(i*2 + " ");
}
}
System.out.println("");
}
}
Gambar : Hasil Class
Asykwae....
public class PengurutanGanjil{
public static void main(String args[]){
for(int i = 1; i<=10; i++){
if (i%2==0){
System.out.println(i + " ");
}
}
System.out.println("");
}
}
Gambar : Hasil Class
http://Ndelokwae.blogspot.com
http://Asykwae.blogspot.com
public class Pengurutan{
public static void main(String args[]){
for(int i = 1; i<=10; i++){
System.out.println(i + " ");
}
System.out.println("");
}
}
Gambar : Hasil Class
Ndelokwae yooo....
public class GanjilGenap{
static int a = 100;
public static void main(String args[]){
if(a%2 == 0){
System.out.println(a + " adalah bilangan genap");
}else{
System.out.println(a + " adalah bilangan ganjil");
}
}
}
Gambar : Hasil Class
public class PiramidaAngka{
public static void main (String args[]){
for(int a=4;a>=0;a--){
for(int b=1;b<=a;b++){
System.out.print(b+"");
}
System.out.println("");
}
System.out.println("");
}
}
Gambar ; Hasil Class
Asykwae....
public class PiramidaAngka{
public static void main (String args[]){
for(int a=4;a>=0;a--){
for(int b=1;b<5-a;b++){
System.out.print(b+"");
}
System.out.println("");
}
System.out.println("");
}
}
Gambar : hasil Class
#include
#include
void main(){
// Inisialisai Variable
int tahun,hari;
int pilihan;
char ulang='y';
while(ulang=='y'){
cout<<"\t Menu\n";
cout<<"* ================================="<
cout<<"* 2. Nama Hari\n";
cout<<"* ================================="<
cin>>pilihan;
if (pilihan==1){
cout<<"\n";
cout<<"\t*** Tahun Kabisat ***"<
cin>>tahun;
if(tahun%4==0){
cout<<"Tahun Kabisat"<
cout<<"Bukan Tahun Kabisat"<
}else if(pilihan==2){
cout<<"\n";
cout<<"\t *** Nama Hari ***"<
cout<<"\n*\t 1. Senen\t*";
cout<<"\n*\t 2. Selasa\t*";
cout<<"\n*\t 3. Rabu\t*";
cout<<"\n*\t 4. Kamis\t*";
cout<<"\n*\t 5. Jum'at\t*";
cout<<"\n*\t 6. Sabtu\t*";
cout<<"\n*\t 7. Minggu\t*";
cout<<"\n* =====================\t*"<
cin>>hari;
if(hari==1){
cout<<"Senin"<
cout<<"Selasa"<
cout<<"Rabu"<
cout<<"Kamis"<
cout<<"Jum'at"<
cout<<"Sabtu"<
cout<<"Minggu"<
}
cout<<"\n";
cout<<"\n";
cout<<"Lanjutkan (y/t) :";
ulang=getch();
cout<<"\n";
cout<<"\n";
}
}
Di Delokwae yooo....
#include
#include
void rumus(int pilihan);
void main(){
int pilihan;
cout<<" Menetukan Hari\n";
cout<<"*=======================*\n";
cout<<"* 1. Senin *\n";
cout<<"* 2. Selasa *\n";
cout<<"* 3. Rabu *\n";
cout<<"* 4. Kamis *\n";
cout<<"* 5. Jumat *\n";
cout<<"* 6. Sabtu *\n";
cout<<"* 7. Minggu *\n";
cout<<"========================*\n";
cout<<"Masukkan Kode Hari = ";
cin>>pilihan;
cout<
if (pilihan==1){
cout<<"Senin"<
cout<<"Selasa"<
cout<<"Rabu"<
cout<<"Kamis"<
cout<<"Jumat"<
cout<<"Sabtu"<
cout<<"Minggu"<
cout <<"Menu hanya untuk 1-7";
}
getch();
}
Jangan Salah yaaaa....
#include
#include
#include
using namespace std;
void rumus(int pilihan, double bil1, double bil2 );
void main(){
system ("COLOR 0A");
string terus;
int pilihan ;
double a,b;
do
{
cout << "=====================\n";
cout << "\tMenu\n";
cout << " 1. Penambahan\n";
cout << " 2. Pengurangan\n";
cout << " 3. Perkalian\n";
cout << " 4. Pembagian\n";
cout << "=====================\n";
cout << "Masukkan Pilihan = ";
cin >> pilihan ;
cout << endl;
cout << "Masukkan angka 1 = ";
cin >> a;
cout << "Masukkan angka 2 = ";
cin >> b;
rumus(pilihan,a,b);
cout << endl;
do{
cout << "Lanjutkan (Y/T)?: ";
cin >> terus;
}while(terus != "Y" && terus != "y" && terus != "T" && terus != "t");
}while(terus != "T" && terus != "t");
}
void rumus(int pilihan, double bil1, double bil2 ){
double hasil;
if(pilihan==1){
hasil = bil1 + bil2;
cout << "Hasil Penjumlahan = " << hasil << endl;
}else if(pilihan==2){
hasil = bil1 - bil2;
cout << "Hasil Pengurangan = " << hasil << endl;
}else if(pilihan==3){
hasil = bil1 * bil2;
cout << "Hasil Perkalian = " << hasil << endl;
}else if(pilihan==4){
hasil = bil1 /bil2;
cout << "Hasil Pembagian = " << hasil << endl;
}else {
cout << "Menu hanya untuk 1 -4";
}
}
Suksesss.....
void main (){
int faktorial;
cout <<"masukkan faktorial ="; cin >> faktorial;
for(int a=faktorial-1; a>0; a--){
faktorial = faktorial * a;
}
cout<< "hasil= "<
getch();
}
Selamt Mencoba...
#include
#include
void main(){
int bil, jum, i;
cout <<"Masukkan sebuah bilangan bulat positif; "; cin >> bil;
jum = 0;
for (i =1; i <= bil; i++)
if (bil % i == 0)
jum++;
if (jum == 2){
cout << "Bilangan Prima\n";
}else{
cout << "Bukan Bilangan Prima\n";
}
getch();
}
Ok Selamat Mencoba.....
Copyright 2010 Ndelokwae - Blog mencari ilmu