Java: Multiplication table string needs to be modified to get spaces in between each character -
so im trying make string in java displays multiplication table tab in between each number in java. im looking modifier adds more spaces between each character. heres code have done , need modify table of strings have spaces in between each number "1 2 3 4" instead of "1 2 3 4".
import java.util.*; public class multtable { public static void main(string[] args) { string y = ("1 23 " + "12345"); system.out.println("1 2 3 4 5 6 7 8 9 10"); system.out.println("2 4 5 8 10 12 14 16 18 20"); system.out.println("3 6 9 12 15 18 21 24 27 30"); system.out.println("4 8 12 16 20 24 28 32 36 40"); system.out.println("5 10 15 20 25 30 35 40 45 50"); system.out.println("6 12 18 24 30 36 42 48 54 60"); system.out.println("7 14 21 28 35 42 49 56 63 70"); system.out.println("8 16 24 32 40 48 56 64 72 80"); system.out.println("9 18 27 36 45 54 63 72 81 90"); system.out.println("10 20 30 40 50 60 70 80 90 100"); } }
try this
public static void main(string[] args) { for(int = 1; <= 10; i++) { for(int j = 1; j <= 10; j++) { system.out.print(i*j + "\t"); } system.out.println(); } }
if want more space between numbers, add first system.out.print() add tab use scape sequence "\t"
Comments
Post a Comment