import java.util.*; //memanggil library "util"
class konversijarak1
{
public static void main(String[] args)
{
//pembuatan variabel
int nilai,pilih;
double hasil;
String jawab;
System.out.println("Program Konversi
Jarak \n ");
jawab = "Y";
do
{
System.out.print("\n Pilihan \n");
System.out.print("\n1. Kilometer -
meter\n");
System.out.print("\n2. Meter -
Kilometer\n");
System.out.print("\n Masukkan
Pilihan:");
pilih=new Scanner(System.in).nextInt();
if(pilih==1)
{
System.out.println("Masukkan Nilai
(KiloMeter):");
nilai = new Scanner(System.in).nextInt();
hasil=nilai*1000;
System.out.print("\n Jarak "+ nilai
+ " Kilo meter =" + hasil + " Meter ");
}
else
{
System.out.println("Masukkan Nilai
(Meter):");
nilai = new Scanner(System.in).nextInt();
hasil=nilai/1000;
}
System.out.print("\n Jarak "+ nilai
+ " Meter =" + hasil + " Kilometer ");
System.out.println("\n \n Apakah Anda
Ingin Mengulang:");
jawab=new Scanner(System.in).nextLine();
}while((jawab.equals("Y"))||(jawab.equals("y"))
);
}
}
Tidak ada komentar:
Posting Komentar