Monday, May 21, 2012

How to print multi-digit numbers like a 7-segment display

I am just wondering whether is it possible to display in digital format.
In this we are accepting number from console.



For example:



123 should be display in following format, and in one line.
_ _
| _| _|
| |_ _|


I tried using switch case but not got appropriate method



"arg" is char array;
char c;
for(i=0;i<3;i++)
{
c=arg[i];
switch(char)
{

case '1' : System.out.println("|");
System.out.println("|");
break;
case '2' : System.out.println("-");
System.out.println(" "+"|");
System.out.println("-");
System.out.println("|");
System.out.println("-");
break;

same for all digit
}
}


I know this is not a correct solution to display.



Is it any alternative for this using java.





No comments:

Post a Comment