[Solved] Print the following 1 2 3 4 Bus 6 7 8 9 bUs 11 12 13 14 buS [closed]
Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(i=1; i<=n; i++) { if(i%3==2 && i%5==0) { System.out.println(“Bus”); } else if(i%3==1 && i%5==0) { System.out.println(“bUs”); } else if(i%3==0 && i%5==0) { System.out.println(“buS”); } else { System.out.println(i+” “); } } System.out.println does not mean it will not go through the next piece of code. You need either an else as … Read more