Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python coding, can someone help me fix my code? #------------------------------------------------------------------------------- #birthmontha = int(input(Enter the birth month of Person A:)) #birthdaya = int(input(Enter the birth day

python coding, can someone help me fix my code?image text in transcribedimage text in transcribed

#------------------------------------------------------------------------------- #birthmontha = int(input("Enter the birth month of Person A:")) #birthdaya = int(input("Enter the birth day of Person A:")) #birthyeara = int(input("Enter the birth year of Person A:")) #-----------------------------------------------------------------------------------

#birthmonthb = int(input("Enter the birth month of Person B:")) #birthdayb = int(input("Enter the birth day of Person B:")) #birthyearb = int(input("Enter the birth year of Person B:")) #----------------------------------------------------------------------------------- #----------------------------------------------------------------------------------- #if birthmonthb 28: #print("You entered an invalid date. Try again!") #elif birthmonthb == 9 or 4 or 6 or 11: #if birthdayb > 30: #print("You entered an invalid date. Try again!") #else: #birthmonthb == 1 or 3 or 5 or 7 or 8 or 10 or 12: #if birthdayb > 31: #print("You entered an invalid date. Try again!") #else: #print ("You entered an invalid date. Try again!") #-----------------------------------------------------------------------------------

#if birthmontha > 12: #print ("You entered an invalid date. Try again!") #if birthyeara % 4 ==0: #if birthmontha == 2: #if birthdaya > 28: #print("You entered an invalid date. Try again!") #elif birthmontha == 9 or 4 or 6 or 11: #if birthdaya > 30: #print("You entered an invalid date. Try again!") #elif birthmontha == 1 or 3 or 5 or 7 or 8 or 10 or 12: #if birthdaya > 31: #print("You entered an invalid date. Try again!") #----------------------------------------------------------------------------------- #if birthyearb birthmonthb: #print("Person B is older!") #elif birthmontha == birthmonthb: #if birthdaya birthdayb: #print("Person B is older!") #elif birthdaya == birthdayb: #print("Person A and Person B have the same age!")

#-----------------------------------------------------------------------------------

#else: #print("cool")

Problem #3: Birthday Comparison Note: This program does not require any form of loop. You are writing a program which compares two birthdays and reports which person is older - or if they are the same age. While simple for a human, this requires quite a few steps for a computer, Follow the following format: Create boolean variables to store whether Date A and Date B are valid. Set them to True; the check later on will detemine if they are false. Prompt the user to enter Date A followed by Date B. Each date has a month, day, and year, and each of these values should be stored in different variables (so month_A, day_A, year_A, and so on). Check to see if the dates are valid - Check date A, then check date B. Depending on the month, a date can have a specific range of dates. April, June, September, and November have days 1-30, Feburary can have days 1-29 (Assume a leap date is possible to input), and the other months can have days 1-31.) If the date is invalid, set the boolean value for that date to false, If both dates are valid: Create boolean values to store if the dates are the same and if date A is older than date B. Assume the former is false and the latter is true; The checks will determine if the former is true and the latter is false. . Compare the dates. Check in the order of year, month, and then day, using nested decision structures to minimize your checks (for example, if year_A is before year_B, then you do not need to check for month and day). If the year, month and day are all the same, then both dates are the same, then the boolean for the dates being the same is true. Otherwise, check to see if Person A is older than Person B, setting the "is Person A older" variable appropriately. . If the users have the same age, tell the user, "Person A and Person B have the same age!" Else, if Person A is older than Person B, tell the user, "Person A is older!" Else, tell the user, "Person B is older!" . Otherwise, tell the user "You entered an invalid date. Try again!" Here are a few sample runnings of the program, with user input bolded: Run #1 Enter the birth month of Person A: 08 Enter the birth day of Person A: 23 Enter the birth year of Person A: 1994 Enter the birth month of Person B: 09 Enter the birth day of Person B: 13 Enter the birth year of Person B: 1994 Person A is older! Run #2 Enter the birth month of Person A: 7 Enter the birth day of Person A: 15 Enter the birth year of Person A: 1996 Enter the birth month of Person B: 7 Enter the birth day of Person B: 10 Enter the birth year of Person B: 1996 Person B is older! Run #3 Enter the birth month of Person A: 9 Enter the birth day of Person A: 18 Enter the birth year of Person A: 1995 Enter the birth month of Person B: 9 Enter the birth day of Person B: 18 Enter the birth year of Person B: 1995 Person A and Person B have the same age! Run #4 Enter the birth month of Person A: 99 Enter the birth day of Person A: 12 Enter the birth year of Person A: 1356 Enter the birth month of Person B: 12 Enter the birth day of Person B: 67 Enter the birth year of Person B: 1495 You entered an invalid date. Try again

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

Calculate the total cost per unit of purchasing from Original Wire.

Answered: 1 week ago