Advertisement
satriafu5710

Tanda Bintang Kelipatan 5 Java

Dec 8th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. package com.tutorial;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         Scanner userInput = new Scanner(System.in);
  9.  
  10.         System.out.println("\t Beri Bintang Pada Kelipatan 5 \n");
  11.  
  12.         System.out.print("Masukkan Batas Nilai : ");
  13.         int nilai = userInput.nextInt();
  14.         for(int i = 1; i <= nilai; i++){
  15.             if(i % 5 == 0){
  16.                 System.out.print("* ");
  17.  
  18.             }else{
  19.                 System.out.print(i + " ");
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement