Program Java : Program Wartel Sederhana

Diposting pada 1.065 views
kemaren sempet searching-searching ga jelas, dapet program wartel sederhana., Semoga bisa membantu. Tapi berhubung saya lupa dimana nie dapat programnya,mohon maaf jadi ga bisa mencantumkan link sumbernya. Tapi kalau saya ingat, pasti saya lampirkan link sumbernya ^^v

coding:

import java.io.*;

public class Wartel
{
public int input()
{
String d;
int c=0;
BufferedReader i = new BufferedReader(new InputStreamReader(System.in));
try
{
d = i.readLine();
c= Integer.parseInt(d);
}
catch(IOException exe)
{
System.out.print("salah input");
}
return c;
}

public static void main(String [] args)
{

int h,m,s,h1,m1,s1,W,P,B,Jum1,Jum2;

Wartel z = new Wartel();
System.out.println("=================================================");
System.out.println("PERUSAHAAN TELEPON");

System.out.print("JAM MULAI BICARA:nn");
System.out.print("Jam : ");
h=z.input();
System.out.print("Menit : ");
m=z.input();
System.out.print("Detik : ");
s=z.input();

System.out.println();
System.out.print("JAM SELESAI BICARA:nn");
System.out.print("Jam : ");
h1=z.input();
System.out.print("Menit : ");
m1=z.input();
System.out.print("Detik : ");
s1=z.input();

if((h<=23) && (m<=59) &&( s<=59) && (h1<=23) && (m1<=59) &&( s1<=59))
{
Jum1=((h*3600)+(m*60)+s);
Jum2=((h1*3600)+(m1*60)+s1);
if (Jum1>Jum2)
{
System.out.println("Inputan salah, Jam Selesai Lebih Besar daripada Jam Mulai");
}
else
{
W=Jum2-Jum1;

P=W/60;

if (W % 60 != 0)
{
P=P+1;
}

System.out.println("nJUMLAH PULSA : "+P);

B=P*100;

System.out.println("nTOTAL BIAYA YANG HARUS DI BAYAR :Rp."+B);

System.out.println("=================================================");
}
}
else
System.out.print("Inputan salah");
}

}

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *