Java—Time
Description
Digital clock use 4 digits to express time, each digit is described by 3*3 characters (including”|”,”_”and” “).now given the current time, please tell us how can it be expressed by the digital clock.
Input
There are several test cases.
Each case contains 4 integers in a line, separated by space.
Proceed to the end of file.
Output
For each test case, output the time expressed by the digital clock such as Sample Output.
Sample
Input
1 2 5 6
2 3 4 2
Output
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner reader = new Scanner(System.in);
int i;
while(reader.hasNext())
{
int s[]=new int [10];
for(i=0;i<4;i++)
{
s[i]=reader.nextInt();
}
for(i=0;i<4;i++)
{
if(s[i]==0)
System.out.print(" "+"_"+" ");
else if(s[i]==1)
System.out.print(" "+" "+" ");
else if(s[i]==2)
System.out.print(" "+"_"+" ");
else if(s[i]==3)
System.out.print(" "+"_"+" ");
else if(s[i]==4)
System.out.print(" "+" "+" ");
else if(s[i]==5)
System.out.print(" "+"_"+" ");
else if(s[i]==6)
System.out.print(" "+"_"+" ");
else if(s[i]==7)
System.out.print(" "+"_"+" ");
else if(s[i]==8)
System.out.print(" "+"_"+" ");
else if(s[i]==9)
System.out.print(" "+"_"+" ");
}
System.out.println();
for(i=0;i<4;i++)
{
if(s[i]==0)
System.out.print("|"+" "+"|");
else if(s[i]==1)
System.out.print(" "+" "+"|");
else if(s[i]==2)
System.out.print(" "+"_"+"|");
else if(s[i]==3)
System.out.print(" "+"_"+"|");
else if(s[i]==4)
System.out.print("|"+"_"+"|");
else if(s[i]==5)
System.out.print("|"+"_"+" ");
else if(s[i]==6)
System.out.print("|"+"_"+" ");
else if(s[i]==7)
System.out.print(" "+" "+"|");
else if(s[i]==8)
System.out.print("|"+"_"+"|");
else if(s[i]==9)
System.out.print("|"+"_"+"|");
}
System.out.println();
for(i=0;i<4;i++)
{
if(s[i]==0)
System.out.print("|"+"_"+"|");
else if(s[i]==1)
System.out.print(" "+" "+"|");
else if(s[i]==2)
System.out.print("|"+"_"+" ");
else if(s[i]==3)
System.out.print(" "+"_"+"|");
else if(s[i]==4)
System.out.print(" "+" "+"|");
else if(s[i]==5)
System.out.print(" "+"_"+"|");
else if(s[i]==6)
System.out.print("|"+"_"+"|");
else if(s[i]==7)
System.out.print(" "+" "+"|");
else if(s[i]==8)
System.out.print("|"+"_"+"|");
else if(s[i]==9)
System.out.print(" "+"_"+"|");
}
System.out.println();
}
}
}