Sunday, December 27, 2015

Java KingKong Program

Java KingKong Program:



package javaapplication16;


public class KingKongDemo {
    public static void main(String[] args) {
        for(int i=1;i<=50;i++){
        
            if(i%3==0){
                System.out.println(i+"King");
            }
            else if(i%5==0){
                System.out.println(i+"kong");
            }
            else if(i%3==0 && i%5==0){
                System.out.println("KingKong");
            }else{
                System.out.println(i);
            }
        }
    }
}

OUTPUT:

1
2
3King
4
5kong
6King
7
8
9King
10kong
11
12King
13
14
15King
16
17
18King
19
20kong
21King
22
23
24King
25kong
26
27King
28
29
30King
31
32
33King
34
35kong
36King
37
38
39King
40kong
41
42King
43
44
45King
46
47
48King
49
50kong



0 comments:

Post a Comment