I have a long string and everything is right, but I am unable to get the same output as the prof. He has a more uniform output. So first I tried to do a system.out.println(), but that did not work.
This is my code:
System.out.println("Password = " + password + "\t\t" + "Newline = " + ctnline + "\t" + "Single = " + ctlength + "\t" + "Equal = " + ctequal + "\t" + "Lenght = " + ctlength2 + "\t" + "Upper = " + ctupper + "\t" + "Lower = " + ctlower + "\t" + "Special = " + (ctspec2));
This was the output:
Password = bank,Rabbither Newline = 0 Single = 2 Equal = 0 Lenght = 1 Upper = 2 Lower = 0 Special = 1
Password = acrossShemoment, Newline = 0 Single = 3 Equal = 0 Lenght = 2 Upper = 9 Lower = 0 Special = 0
Password = her.theyOWN Newline = 0 Single = 6 Equal = 0 Lenght = 3 Upper = 9 Lower = 0 Special = 1
Password = ALICEeyes.said Newline = 0 Single = 0 Equal = 0 Lenght = 0 Upper = 0 Lower = 0 Special = 0
Password = thepackKing. Newline = 0 Single = 1 Equal = 0 Lenght = 3 Upper = 4 Lower = 0 Special = 1
Password = thethatKing. Newline = 0 Single = 1 Equal = 0 Lenght = 0 Upper = 2 Lower = 0 Special = 0
Password = AfterWhichdear! Newline = 0 Single = 1 Equal = 0 Lenght = 1 Upper = 3 Lower = 0 Special = 0
Password = "Silencethecrown Newline = 0 Single = 1 Equal = 1 Lenght = 6 Upper = 8 Lower = 0 Special = 0
Password = "Silencemuchme Newline = 0 Single = 6 Equal = 0 Lenght = 1 Upper = 6 Lower = 0 Special = 2
Password = King.nopeeped Newline = 0 Single = 5 Equal = 0 Lenght = 2 Upper = 9 Lower = 0 Special = 2
Password = eitherKing.Soon Newline = 0 Single = 0 Equal = 0 Lenght = 0 Upper = 0 Lower = 0 Special = 0
That did not work, the teacher has an output where the "newline" is aligned together.
I need the output to be like this (how the teacher has it):
Password = bank,Rabbither Newline = 0 Single = 2 Equal = 0 Lenght = 1 Upper = 2 Lower = 0 Special = 1
Password = acrossShemoment, Newline = 0 Single = 3 Equal = 0 Lenght = 2 Upper = 9 Lower = 0 Special = 0
Password = her.theyOWN Newline = 0 Single = 6 Equal = 0 Lenght = 3 Upper = 9 Lower = 0 Special = 1
Password = ALICEeyes.said Newline = 0 Single = 0 Equal = 0 Lenght = 0 Upper = 0 Lower = 0 Special = 0
Password = thepackKing. Newline = 0 Single = 1 Equal = 0 Lenght = 3 Upper = 4 Lower = 0 Special = 1
Password = thethatKing. Newline = 0 Single = 1 Equal = 0 Lenght = 0 Upper = 2 Lower = 0 Special = 0
Password = AfterWhichdear! Newline = 0 Single = 1 Equal = 0 Lenght = 1 Upper = 3 Lower = 0 Special = 0
Password = "Silencethecrown Newline = 0 Single = 1 Equal = 1 Lenght = 6 Upper = 8 Lower = 0 Special = 0
Password = "Silencemuchme Newline = 0 Single = 6 Equal = 0 Lenght = 1 Upper = 6 Lower = 0 Special = 2
Password = King.nopeeped Newline = 0 Single = 5 Equal = 0 Lenght = 2 Upper = 9 Lower = 0 Special = 2
Password = eitherKing.Soon Newline = 0 Single = 0 Equal = 0 Lenght = 0 Upper = 0 Lower = 0 Special = 0
I've never learnt how to use printf, thats how they were showing it online when I was looking up a solution. Is there any other way to format is properly while printing. I'm not sure if we can use printf or not since the teacher never taught it.
Edit: I’m allowed to use the String.format() method.