9th Jun 2024, 9:37 PM
Aqeel
Aqeel - avatar
1 Réponse
+ 1
using + instead of concat in your println could make your code more readable. import java.util.Scanner; public class Main { private static final Scanner user = new Scanner(System.in); public static void main(String[] args) { System.out.println("Enter your name."); String name = user.nextLine(); int count = 0; for(char c: name.toCharArray()) System.out.printf( "This letter number %2d %2s --> %8s\n", ++count,c,Integer.toBinaryString(c)); System.out.println("You put " + count + " letters\nYour text is " + name); } }
11th Jun 2024, 6:19 AM
Bob_Li
Bob_Li - avatar