import java.util.Scanner;
public class wartel{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
/*Menghitung Biaya wartel selam x jam, y menit, z detik */
System.out.println ("=================================================");
System.out.println ();
System.out.println (" WARTEL D'EXACTA ");
System.out.println ();
/*Input waktu lama panggilan */
System.out.println ("JAM MULAI BICARA\t");
System.out.print ("JAM \t: ") ;
double a = input.nextDouble();
System.out.print ("MENIT \t: ") ;
double b = input.nextDouble();
System.out.print ("DETIK \t: ") ;
double c = input.nextDouble();
System.out.println ("\nJAM SELESAI BICARA\t");
System.out.print ("JAM \t: ") ;
double x = input.nextDouble();
System.out.print ("MENIT \t: ") ;
double y = input.nextDouble();
System.out.print ("DETIK \t: ") ;
double z = input.nextDouble();
/*Rumus perhitungannya, waktu akhir di kurang waktu awal */
double waktu = ((x-a)*3600)+((y-b)*60)+(z-c);
System.out.println("LAMA WAKTU TELEPON ADALAH (dalam detik)\t:" +waktu);
/*1 pulsa = 5 detik dan 1 pulsa harganya Rp. 150*/
double pulsa = waktu / 5 ;
double harga = pulsa * 150;
System.out.println("\nJUMLAH PULSA\t\t\t\t: " +pulsa);
System.out.println("\nTOTAL BIAYA YANG HARUS DI BAYAR\t\t:Rp." +harga);
System.out.println("=================================================");
}
}
keluarannya kayak gini.
Happy Java. :)