In this program user enters a date in digital
format and the java program will display it in text format.
The entered value will be like 01012014 and the
output will be 1 January 2014
import java.io.*;
class DigitDate
{
int
number,d,m,y;
String
mon;
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
public
void takeDate()throws Exception
{
System.out.println("Enter the date in digital format:");
number=Integer.parseInt(br.readLine());
y=number%10000;
number=number/10000;
m=number%100;
d=number/100;
System.out.print("Entered date in text format:"+d+ "
");
switch(m)
{
case 1:
mon="January";
break;
case 2:
mon="February";
break;
case 3:
mon="March";
break;
case 4:
mon="April";
break;
case 5:
mon="May";
break;
case 6:
mon="June";
break;
case 7:
mon="July";
break;
case 8:
mon="August";
break;
case 9:
mon="Septembery";
break;
case
10:
mon="October";
break;
case
11:
mon="November";
break;
case
12:
mon="December";
break;
}
System.out.print(mon + " " + y);
}
public
static void main(String args[])throws Exception
{
DigitDate
object=new DigitDate ();
object.takeDate();
}
}
Related Post: BlueJ Programs on Number
No comments:
Post a Comment