Tentang shareilmu2ilmu.blogspot.com

http://shareilmu2ilmu.blogspot.com/ adalah blog tentang komputer yang di buat untuk Pembelajaran, tugas-tugas,aplikasi komputer,Coding,pemograman visual, sistem manajemen basis data

Monday 8 April 2013

Mencari Kelipatan 3 dan 7 yang sama


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pbo1;

/**
 *
 * @author acer
 */
public class Pbo1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int a=0;
        System.out.print("Bilangan kelipatan 3 dan kelipatan 7 antara 10 s/d 75 adalah ");
        for (int i = 10; i<75; i++){
            if(i % 7 ==0 && i % 3 ==0 ){
                System.out.print(i+",");
                a=a+i;
            }
        }
        System.out.println("\nTotal bilangan adalah "+a);
    }
}

Class diagram


Pegawai.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Pegawai
    {
        string nama;

        public string Nama
        {
            get { return nama; }
            set { nama = value; }
        }
        int gapok;

        public int Gapok
        {
            get { return gapok; }
            set { gapok = value; }
        }

        public Pegawai(string nama,Int32 gapok)
        {
            this.nama=nama;
            this.gapok=gapok;
           
        }
        public void profilPegawai()
        {
            Console.WriteLine("========JABATAN PEGAWAI=============");
            Console.WriteLine("Nama: {0}",nama);
            Console.WriteLine("Gaji Pokok:{0}",gapok);
        }
      
    }
}








Manager.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Manager:Pegawai
    {
        int tunjangan, totalgaji;

        public int Totalgaji
        {
            get { return totalgaji; }
            set { totalgaji = value; }
        }

        public int Tunjangan
        {
            get { return tunjangan; }
            set { tunjangan = value; }
        }

        public Manager(string nama,Int32 gapok,Int32 tunjangan, Int32 totalgaji):base (nama,gapok)
        {
            this.tunjangan = tunjangan;
            this.totalgaji = totalgaji;
           
        }
        public void profilManager()
        {
            Console.WriteLine("========JABATAN MANAGER=============");
            base.profilPegawai();
            Console.WriteLine("tunjangan:{0} ", tunjangan);
            Console.WriteLine("Total gaji sebelum lembur:{0} ", tunjangan + Gapok);
        }
    }
}






Karyawan.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Karyawan:Manager 
    {
        int jamlembur, upahlemburperjam;

        public Karyawan(string nama,Int32 gapok,Int32 tunjangan,Int32 totalgaji,int jamlembur,Int32 upahlemburperjam):base (nama,gapok,tunjangan,totalgaji)
        {
            this.Nama = nama;
            this.Gapok = gapok;
            this.Tunjangan = tunjangan;
            this.Totalgaji = totalgaji;
            this.jamlembur = jamlembur;
            this.upahlemburperjam = upahlemburperjam;
     
    }
        public void profilKaryawan()
        {
            Console.WriteLine("========JABATAN KARYAWAN=============");
            base.profilManager();
            Console.WriteLine("Jamlembur :{0}",jamlembur);
            Console.WriteLine("Upah Jam Lembur:{0}",(jamlembur*upahlemburperjam));
           
        }
    }
}









Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Pegawai p1 = new Pegawai("Dion", 50000000);
            p1.profilPegawai();
            Console.WriteLine("");

            Manager m1 = new Manager("Dion", 100000000,3000000,4000000);
            m1.profilManager();
            Console.WriteLine("");

            Karyawan k1 = new Karyawan("Dion", 1500000000, 400000000, 300000000, 24, 400000000);
            k1.profilKaryawan();
            Console.WriteLine("");

            Console.Read();
        }
    }
}