Question

Project 11-1: Birthday Calculator Create a program that accepts a name and a birth date and displays the persons birthday the current day, the persons age, and the number of days until the persons next birthday Console Birthday Calculator Enter name: Joel Enter birthday (MM/DD/YY): 2/4/68 Birthday: Sunday, February 04, 1968 Today: Joel is 48 years old. Joels birthday is in 73 days Tuesday, November 22, 2016 Continue? (y/n): y Enter name: Django Enter birthday (MM/DD/YY): 12/1/07 Birthday: Saturday, December 01, 2007 Today: Django is 8 years old. Django s birthday is in 9 days Tuesday, November 22, 2016 Continue? (y/n): y Enter name: Mike Enter birthday (MM/DD/YY): 11/22/86 Birthday: Saturday, November 22, 1986 Today: Mike is 30 years old. Mikes birthday is today! Tuesday, November 22, 2016 Continue? (y/n): n Specifications Allow the user to enter a date in the MM/DD/YY format. Adjust the date so that it is correct even if the birth year is later than the current year. When you calculate the persons age, dont take leap year into account. If the person is more than 2 years old, display the persons age in years. Otherwise, display the persons age in days When you display the message that indicates the number of days to the persons birthday, you can use the following format for a person with a name of John: today tomorrow yesterday - Johns birthday was yesterday! other days - - Johns birthday is today! Johns birthday is tomorrow! Johns birthday is in X days.

Write in python code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#source code screenshots

File Edit Format Run Options Window Help import datetime print (Birthday Calculatorn) while (1): name - input (Enter name: ) birthdayinput (Enter birthday (MM/DD/YY): ) list = [] list-birthday. split (ソリ mm -int (1ist [0) dd int (1ist [i]) yy -int (list[2]) с 19; if (yy<10): с 200; elif (yy<=18) : c=20 ; yV - int (str (c) +str (yy)) w = datetime.date(yy, mm, dd); print (Birthday: 4w.strftime (%A)+, x - datetime.date.today () print (Today: +w.strftime (%B)+ +w.strftime (%d)+, +str (w.year)) 4x.strftime (%A ) +, +x.strftime (%B)+ +x.strftime (%d ) +, 4str(x.year)) yearsdiff -x.year - yV; days_diff -0; if (mm>x.month): years diff -years_diff-l; y-datetime.date (x.year, mm, dd) daysdiff = diff days; if (dd>x.day) : - elif (mmx.month) years_diff years_diff-l: days diffdd-x.day: if (dd-x.day-1) else: elif (dd<x.day): days diff=-1; y= datetime . date (x.year+1, days diffdiff.days; m, dd) else: y datetime . date (X . year+1, mm, dd) days diffdiff.days:

#code

import datetime
print("Birthday Calculator\n")
while(1):
name = input("Enter name: ")
birthday = input("Enter birthday (MM/DD/YY): ")

list = []
list = birthday.split('/')
mm = int(list[0]);
dd = int(list[1])
yy = int(list[2])

c=19;
if(yy<10):
c=200;
elif(yy<=18):
c=20;
yy = int(str(c)+str(yy))

w = datetime.date(yy, mm, dd);
print("Birthday: "+ w.strftime("%A")+", "+w.strftime("%B")+" "+w.strftime("%d")+", "+str(w.year))
x = datetime.date.today()
print("Today: "+ x.strftime("%A")+", "+x.strftime("%B")+" "+x.strftime("%d")+", "+str(x.year))

years_diff = x.year - yy;
days_diff = 0;
if(mm>x.month):
years_diff = years_diff-1;
y = datetime.date(x.year, mm, dd)
diff = y-x;
days_diff = diff.days;
elif(mm==x.month):
if(dd>x.day):
years_diff = years_diff-1;
days_diff = dd-x.day;
elif(dd<x.day):
if(dd==x.day-1):
days_diff=-1;
else:
y = datetime.date(x.year+1, mm, dd)
diff = y-x;
days_diff = diff.days;
else:
y = datetime.date(x.year+1, mm, dd)
diff = y-x;
days_diff = diff.days;
if(years_diff<2):
print(name+" is "+str(years_diff*365+365-days_diff)+" days old.")
else:
print(name+" is "+str(years_diff)+" years old.")
s = ""
if(days_diff==0):
s="is today!"
elif(days_diff==1):
s="is tomorrow!"
elif(days_diff==-1):
s="was yesterday!"
else:
s="is in "+str(days_diff)+" days.";
print(name+"'s birthday "+s+"\n")
option = input("Continue? (y/n): ")
if(option=='n'):
break;

#output screenshot

#any query, post in comment section

Add a comment
Know the answer?
Add Answer to:
Write in python code Project 11-1: Birthday Calculator Create a program that accepts a name and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that determines the user's age after the   user enters both the current...

    Write a C++ program that determines the user's age after the   user enters both the current date and hisher birthdate as 3   integers:                yyyy mm dd                                                                                             Define a class which is named DateType and will be used to     declare 2 objects: "birthday" and "today". The class will have a function "output" which will display the date in conventional form (like it is above next to Date Assigned: Month dd, yyyy and it will have a second function named     “input”...

  • Coding in C++ Write a program using structures to store the following weather information: - Month...

    Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...

  • Write a program called RentalRate.java which reads in a date of birth, today’s date and a...

    Write a program called RentalRate.java which reads in a date of birth, today’s date and a male/female designation from the user, and will then determine the basic daily and weekly rates for rental of an economy class car. Rental rate classes are: Best rate (male drivers, age 33–65 and female drivers, age 30-62)--$40.00per day, $200.00 per week Risk rate 1 (female drivers, age 25–29)–Best rate plus $10.00 per day or best rate plus $55.00 per week. Risk rate 2 (male...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT