40 Code project
Hello Dear Coders. Can you give me some help. I solved the problem in 40 Code project by myself, but i have feeling like i did it not good. Can you please show me any other way for solving 40 Code project, my way was like that: import java.util.Scanner; public class Program { public static void main(String[] args) { Converter converter = new Converter(); Scanner sc = new Scanner(System.in); int x = sc.nextInt(); converter.setNum(x); System.out.println(converter.toBinary()); } } class Converter{ int num; String binary=""; public void setNum(int setNum){ this.num = setNum; } String toBinary(){ while (num>0){ binary = (num%2)+binary; num /= 2;} return binary; } } thx )