Posts

Showing posts with the label You are given an integer

You are given an integer and you have to convert it into a string - Hacker Rank Solution.

Please complete the partially completed code in the editor. If your code successfully converts     into a string     the code will print " Good job ". Otherwise it will print " Wrong answer ".  can range between   to   inclusive. Sample Input 0 100 Sample Output 0 Good job SOLUTION:- import java.util.*; public class Solution {     public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int n = sc.nextInt();         sc.close();         // Convert the integer to a string         String s = Integer.toString(n);         // Check if the string can be converted back and matches the original         if (n == Integer.parseInt(s)) {             System.out.println( "Good job" );         } else {   ...