Computer Science, asked by pandusanthi2000, 11 months ago

An island called “Wonderland” is filled with treasures. Raj is trying to get the treasure. To get it, he has to reach the end of the snow land in the island but got puzzled in the mid-way by a hint he got there. The hint is stating that to cross the snow land he has to jump on the ice stones which is of pairs else he will be drowned in the cold river. He has to check whether the number of ice stones is in pairs or not. Suggest him a logic to check the pairs of stones and say whether he can get the treasure or not. The input should be an integer. The output should be either Possible or Not possible. [Hint : Use ternary operator]

Answers

Answered by shahid1redflagged7
0

I am using java....

import java.util.Scanner;

public class Wonderland

{

public static void main (String args[])

{

int n_of_icestones;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the number of stones");

n_of_icestones = sc.nextInt();

System.out.println((n_of_icestones%2==0)?"Possible":"Not possible");

}

}

Explanation:

hope you like the answer....

Similar questions