Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.util.Scanner;
- /**
- *
- * @author runsel
- */
- public class c_tes {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- //Tampilkan menu untuk user
- System.out.println("Pilih program : ");
- System.out.println("1. Konversi KM ke M");
- System.out.println("2. Konversi KM ke CM");
- Scanner input = new Scanner(System.in);
- //Terima pilihan menu dari user
- System.out.print("Pilihan anda : ");
- int pilihan = input.nextInt();
- //Terima input batas awal
- System.out.print("Masukkan batas awal : ");
- int awal = input.nextInt();
- //Terima input batas akhir
- System.out.print("Masukkan batas akhir : ");
- int akhir = input.nextInt();
- for(int data=awal; data<=akhir; data++){
- if(pilihan == 1){
- int output = data*1000;
- //Tampilkan hasil
- //Output : 2 Kilometer = 20000 Meter
- System.out.print(data+" Kilometer ");
- System.out.println(output+" Meter");
- }else if(pilihan == 2){
- int output = data*100000;
- //Tampilkan hasil
- //Output : 2 Kilometer = 20000 Centimeter
- System.out.print(data+" Kilometer ");
- System.out.println(output+" Centimeter");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement