casper. Powered by Blogger.

Blog ini bertujuan untuk share ilmu dan pengetahuan. Semua source/aplikasi di blog ini bebas disebar dan mencamtumkan sumber "fandy-alfa.blogspot.com".

RSS

Program Konversi Waktu2

import java.io.*;

public class konversi_waktu2 {
  
    public static void main(String[] args) throws IOException
    {
        int jam=0, menit=0,detik=0;
        int x=0;
       
        BufferedReader stdin=
            new BufferedReader (new InputStreamReader (System.in));
               
        System.out.println("PROGRAM KONVERSI WAKTU");
        System.out.println("======================\n");
       
        System.out.print("Masukkan Jumlah Detik : ");
        int jumlah = Integer.parseInt(stdin.readLine());
       
        if (jumlah < 3600)
        {
            jam=0;
           
            menit=jumlah/60;           
            detik=jumlah%60;
           
        }
       
        else if (jumlah == 3600)
            jam=1;
       
        else if (jumlah >= 3600)
        {                       
            if (jumlah <= 3660)
            {
                jam=1;
                detik=jumlah-3600;
            }
           
            else
            {                           
                for (int i=jumlah; i>60 ; i/=60)
                {               
                    jam=i;
                    jam=jam/60;                               
                    menit=i%60;
                    detik=jumlah-((jam*3600)+(menit*60));           
                }
            }           
        }
       
        System.out.print("Hasil => " + jam + " Jam "+menit+" menit "+detik+" detik ");
    }
}
  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

1 comments:

Anonymous said...

mau contoh program c++ yang lain kunjungi aja http://agussugianta00901343.blogspot.com
http://sugikboy.blogspot.com

Post a Comment