#need help in hackerrank question
3 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @olive harness! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
import java.util.*;
public class Solution {
public static void main(String[] args) {
String s=" ";int j=0,len=0;
Scanner sc = new Scanner(System.in);
System.out.println("================================");
for(int i=0;i<=2;i++)
{
s=sc.nextLine();
j=sc.nextInt();
len=s.length();
System.out.print(s);
for(int k=(16-(len+1));k>=1;k--)
{
System.out.print(' ');
}
if(j>=100 && j<=999)
{
System.out.println(j);
}
else if(j<=100)
{
System.out.println("0"+j);
}
else if(j<=9)
{
System.out.println("00"+j);
}
}
System.out.println("================================");
sc.close();
}
}```