+ 1
Can you make it better than that ?
https://sololearn.com/compiler-playground/co4o0J19sjst/?ref=app
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);
}
}