0% found this document useful (0 votes)
6 views1 page

Java Input Formatting Example

The Java program takes user input for a string and an integer three times. It formats the integer with leading zeros based on its value and prints the string followed by the formatted integer. The output is enclosed within a decorative line of equal signs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Java Input Formatting Example

The Java program takes user input for a string and an integer three times. It formats the integer with leading zeros based on its value and prints the string followed by the formatted integer. The output is enclosed within a decorative line of equal signs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class Main{


public static void main(String args[]){
String s = new String();
[Link]("================================");
for(int i=0;i<3;i++){
Scanner sc = new Scanner([Link]);
s = [Link]();
n = [Link]();
}
for(int i=0;i<3;i++){
if(n<10){
[Link](s+" "+"00"+n);
}
else if(n<100){
[Link](s+" "+"0"+n);
}
else{
[Link](s+" "+n);
}
}
[Link]("================================");

}
}

You might also like