#5 Java Output Formatting | Hackerrank Java Solutions

preview_player
Показать описание
Thanks if u r Watching us....
#Python #Dev19 #HackerankSolutions #C #C++ #Java #Python #C
Please Subscribe Us ....
Рекомендации по теме
Комментарии
Автор

why we use printf ?? and why we use %s %d ?? in java we not write in this way??

karishmasharma
Автор

Could You explain me? ki apne string values ko access krne ke liye only next ka use kyo kiya instead of nextLine().

deepssne
Автор

am i the only one who is not understanding the basics also

Kafi_relatable
Автор

why you used printf insteaadof println()

rajendrakendre
Автор

public static void main(String[] args) {
Scanner sc=new Scanner(System.in);

String space = "" ;
for(int i=0;i<3;i++){
String s1=sc.next();
int x=sc.nextInt();

//Complete this line

int k = s1.length();
for (int j =0 ; j<15-k;j++)
{
space = space+" ";
}
if (x%100 == x && x !=0 && x!= 00)
{
System.out.print (s1+space+"0"+x+"\n");
space = "";
}
else if (x == 0)
{System.out.print (s1+space+"00"+x+"\n");
space = "";}

else {System.out.print (s1+space+x+"\n");
space = "";}
}



i wrote this and it passed the test, I think I used poor Logic, don't hate me please lol

ketul