samedi 23 juillet 2016

How to print in this format?

code :

import java.util.Scanner;

class Plalindrome {

    public static void main(String[] args) {
       Scanner obj = new Scanner(System.in);

       int n = obj.nextInt();
       for(int i = 0; i < n; i++) {
            int s = obj.nextInt();
            if(s==6) {
                System.out.println("noon");
            }
            if(s==7) {
                System.out.println("radar");
            }
            if(s==2) {
                System.out.println("ab");
            }
        }
    }
}

output :

run:
2
6
noon
7
radar

but I want the output like this

Input:

3
6
7
2

Output:

noon
radar
ab

What I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire