The program should display the following day from a given input.
---INPUT---
Enter day: 31
Enter month: 3
Enter year: 2013
---OUTPUT---
Day: 1
Month: 4
Year: 2013
__________________________________________________________________________________
OUTPUT OF PROGRAMS:
__________________________________________________________________________________
PROGRAM STRUCTURE:
#!/usr/bin/perl -w
print"\nEnter day: ";
$days=<STDIN>;
print"\nEnter month: ";
$month=<STDIN>;
print"\nEnter a year: ";
$year=<STDIN>;
print"\n";
$d1=1;
if($month<=12)
{
if($year%4==0)
{
if($month==1||$month==3||$month==5||$month==7||$month==8||$month==10)
{
if($days==31)
{
print"days:1\n";
$monthM=$month+1;
print"month:$monthM\n";
print"Year:$year\n";
}
elsif($days<31){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
elsif($month==4||$month==6||$month==5||$month==9||$month==11)
{
if($days==30)
{
print"days:1\n";
$monthM=$month+1;
print"month:$monthM\n";
print"Year:$year\n";
}
elsif($days<30){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
elsif($month==2)
{
if($days==29)
{
print"days:1\n";
$monthM=$month+1;
print"month:$monthM\n";
print"Year:$year\n";
}
elsif($days<29){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
elsif($month==12)
{
if($days==31)
{
print"days:1\n";
$monthM=$month+1;
print"month:1\n";
$year1=$year+1;
print"Year:$year1\n";
}
elsif($days<31){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
}
elsif($year%4!=0)
{
if($month==1||$month==3||$month==5||$month==7||$month==8||$month==10)
{
if($days==31)
{
print"days:1\n";
$monthM=$month+1;
print"month:$monthM\n";
print"Year:$year\n";
}
elsif($days<31){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
elsif($month==4||$month==6||$month==5||$month==9||$month==11)
{
if($days==30)
{
print"days:1\n";
$monthM=$month+1;
print"month:$monthM\n";
print"Year:$year\n";
}
elsif($days<30){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
elsif($month==2)
{
if($days==28)
{
print"days:1\n";
$monthM=$month+1;
print"month:$monthM\n";
print"Year:$year\n";
}
elsif($days<28){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
elsif($month==12){
if($days==31)
{
print"days:1\n";
$monthM=$month+1;
print"month:1\n";
$year1=$year+1;
print"Year:$year1\n";
}
elsif($days<31){
$days=$days+$d1;
print"Day:$days\n";
print"month:$month\n";
print"Year:$year\n";
}
else {print"error day\n"}
}
}
}
else{print"wrong input. please input actual days and month\n"};
print"Question 1 end\n";