/*
Nengo 0.4
English Edition
CopyLeft (←) 2004 by KIKIstar SoftStyle. a Bunki program.
http://kikistar.y365.com
kikistar@126.com
*/
#include
#include
char index, index_2, i;
void case_1();
void case_2();
void getindex();
void JtoAD();
main()
{
clrscr();
do
{
printf("\n\n\t\t 1. Change A.D. year to Japanese year \n");
printf("\n\t\t 2. Change Japanese year to A.D. year \n");
printf("\n\t\t 3. Exit. \n\n");
printf("\n Please select a number: ");
getindex();
switch(index){
case '1' : clrscr(); case_1(); break;
case '2' : clrscr(); case_2(); break;
case '3' : printf("\n\n\tThank you for using this program! Bye!");break;
}
if (index != '1' && index != '2' && index != '3'){
clrscr();
printf("\007\n Please selected 1, 2 or 3\n");
}
}while(index != '3');
}
int AD_year, J_year;
char back[100];
void case_1()
{
while(1)
{
printf("\n Now you can input a A.D.year, and I will change it to the Japanese year.");
printf("\n If you want to back to the main menu, just input \"back\".\n");
printf("\n A.D.");
AD_year = 0;
scanf("%d", &AD_year);
gets(back); /* it must follow the scanf */
if ((strcmp(back, "back")) == 0)
break;
clrscr();
switch (AD_year){
case 1868 : printf("\n The year A.D.1868 is Meiji gannen\(Meiji 1 nen\)\n");break;
case 1912 : printf("\n The year A.D.1912 is Taisyou gannen\(Taisyou 1 nen\)\n");break;
case 1926 : printf("\n The year A.D.1926 is Syouwa gannen\(Syouwa 1 nen\)\n");break;
case 1989 : printf("\n The year A.D.1989 is Heisei gannen\(Heisei 1 nen\)\n");break;
}
if (AD_year > 1868 && AD_year < 1912){
J_year = AD_year - 1868 + 1;
printf("\n The year A.D.%d is Meiji %d nen.\n", AD_year, J_year);
}
else if (AD_year > 1912 && AD_year < 1926){
J_year = AD_year - 1912 + 1;
printf("\n The year A.D.%d is Taisyou %d nen.\n", AD_year, J_year);
}
else if (AD_year > 1926 && AD_year < 1989){
J_year = AD_year - 1926 + 1;
printf("\n The year A.D.%d is Syouwa %d nen.\n", AD_year, J_year);
}
else if (AD_year > 1989 && AD_year <= 2046){
J_year = AD_year - 1989 + 1;
printf("\n The year A.D.%d is Heisei %d nen.\n", AD_year, J_year);
}
else
printf("\007\n Please input a year between A.D.1868 and A.D.2046\n");
}
clrscr();
}
char nengo[8];
int last, first;
void case_2()
{
while(index != '5'){
printf("\n\t\t\t 1. Meiji\n");
printf("\n\t\t\t 2. Taisyou\n");
printf("\n\t\t\t 3. Syouwa\n");
printf("\n\t\t\t 4. Heisei\n");
printf("\n\t\t\t 5. Back to the main menu.\n");
printf("\n Please select a nengo \( a title of the Japanese year \): ");
getindex();
switch (index){
case '1': {
strcpy(nengo, "Meiji");
last = 45;
first = 1868;
JtoAD();
break;
}
case '2': {
strcpy(nengo, "Taisyou");
last = 15;
first = 1912;
JtoAD();
break;
}
case '3': {
strcpy(nengo, "Syouwa");
last = 64;
first = 1926;
JtoAD();
break;
}
case '4': {
strcpy(nengo, "Heisei");
last = 58;
first = 1989;
JtoAD();
}
}
if (index != '1' && index != '2' && index != '3' && index != '4' && index != '5'){
clrscr();
printf("\007\n Sorry, it seems that you've input a wrong number.\n");
printf("\n Please choose a number from the menu below.\n");
}
}
index = '2';
clrscr();
}
void getindex()
{
i = 1;
while ((index_2 = getchar()) != 10){
if (i == 1) /* if remove this IF, index will always be 10 */
index = index_2;
++i;
}
if (i > 2)
index = '0';
}
void JtoAD()
{
printf("\n Now you can input a %s year, than I will change it into the A.D. year.\n", nengo);
i = 1;
while(i == 1){
printf("\n %s : ", nengo);
scanf("%d", &J_year);
gets(back);
if (J_year >= 1 && J_year <= last){
AD_year = J_year + first - 1;
clrscr();
printf("\n The year %s %d nen is A.D.%d \n", nengo, J_year, AD_year);
++i;
}
else
printf("\007\n Error! Please input a number between 1 and %d \n", last);
}
}