Question

In: Computer Science

In Java please: 5.23 LAB: Seasons Write a program that takes a date as input and...

In Java please:

5.23 LAB: Seasons

Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day.

Ex: If the input is:

April
11

the output is:

Spring

In addition, check if the string and int are valid (an actual month and day).

Ex: If the input is:

Blue
65

the output is:

Invalid 

The dates for each season are:
Spring: March 20 - June 20
Summer: June 21 - September 21
Autumn: September 22 - December 20
Winter: December 21 - March 19

Solutions

Expert Solution

if __name__ == '__main__':
    inputMonth = input()
    inputDay = int(input())

    if inputMonth == "January" and 1 <= inputDay <= 31:
        print("Winter")
    elif inputMonth == "February" and 1 <= inputDay <= 29:
        print("Winter")
    elif inputMonth == "April" and 1 <= inputDay <= 30:
        print("Spring")
    elif inputMonth == "May" and 1 <= inputDay <= 30:
        print("Spring")
    elif inputMonth == "July" and 1 <= inputDay <= 31:
        print("Summer")
    elif inputMonth == "August" and 1 <= inputDay <= 31:
        print("Summer")
    elif inputMonth == "October" and 1 <= inputDay <= 31:
        print("Autumn")
    elif inputMonth == "November" and 1 <= inputDay <= 30:
        print("Autumn")
    elif inputMonth == "March" and 20 <= inputDay <= 31:
        print("Spring")
    elif inputMonth == "June" and 1 <= inputDay <= 20:
        print("Spring")
    elif inputMonth == "June" and 21 <= inputDay <= 30:
        print("Summer")
    elif inputMonth == "September" and 1 <= inputDay <= 21:
        print("Summer")
    elif inputMonth == "September" and 22 <= inputDay <= 30:
        print("Autumn")
    elif inputMonth == "December" and 0 <= inputDay <= 20:
        print("Autumn")
    elif inputMonth == "December" and 21 <= inputDay <= 30:
        print("Winter")
    elif inputMonth == "March" and 1 <= inputDay <= 19:
        print("Winter")
    else:
        print("Invalid")

Related Solutions

Write a program that takes a date as input and outputs the date's season. The input...
Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day. Ex: If the input is: April 11 the output is: Spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is: Blue 65 the output is: Invalid The dates for each season are: Spring: March 20 - June 20 Summer:...
Write a program in python that takes a date as input and outputs the date's season....
Write a program in python that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day. Ex: If the input is: April 11 the output is: Spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is: Blue 65 the output is: Invalid The dates for each season are: Spring: March 20 - June...
in Java, write a program that takes an input of 4 numbers and splits them into...
in Java, write a program that takes an input of 4 numbers and splits them into 4 separate lines. EXAMPLE: so if input is 1994 the output should be 1 9 9 4
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers...
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers for height and width and uses a nested for loop to make a rectangle out of asterixes. The creation of the rectangle (i.e. the nested for loop) should occur in a void function that takes in 2 parameters, one for height and one for width. Make sure your couts match the sample output (copy and paste from those couts so you don't make a...
Write a Java application with a JavaFXGUI that takes a String input by the user and...
Write a Java application with a JavaFXGUI that takes a String input by the user and shows whether the string contains all 26 letters of the (English version of the Latin) alphabet. For example, "Pack my box with five dozen liquor jugs" contains all 26 letters, but "The quick frown box jumps over the hazy log" does not contain a d. It does not matter whether one or more letters appear more than once. The GUI needs, at minimum, a...
Write a Java application with a JavaFXGUI that takes a String input by the user and...
Write a Java application with a JavaFXGUI that takes a String input by the user and shows whether the string contains all 26 letters of the (English version of the Latin) alphabet. For example, "Pack my box with five dozen liquor jugs" contains all 26 letters, but "The quick frown box jumps over the hazy log" does not contain a d. It does not matter whether one or more letters appear more than once. The GUI needs, at minimum, a...
Write a java program that will ask for a Star Date and then convert it into...
Write a java program that will ask for a Star Date and then convert it into the corresponding Calendar date. without using array and methods.
In Java Please!!! 6.22 LAB: Python and sqlite basics Write a Python program that connects to...
In Java Please!!! 6.22 LAB: Python and sqlite basics Write a Python program that connects to a sqlite database. Create a table called Horses with the following fields: id (integer): a primary key and not null name (text) breed (text) height (real) birthday (text) Next, insert the following data row into the Horses table: id: 1 name: 'Babe' breed: 'Quarter Horse' height: 15.3 birthday: '2015-02-10' Output all records from the Horses table. Ex: With the above row inserted, the output...
In Java please: 3.39 Lab 6e: CharacterOps Write a program that prompts the user to enter...
In Java please: 3.39 Lab 6e: CharacterOps Write a program that prompts the user to enter their first name. Say hello to the person. Then display whether their name begins with a vowel or consonant. If it is neither, perhaps a special character or a number digit, then print neither a vowel nor a consonant. Example 1: Enter your first name: Barbara Hello, Barbara! The first letter of your name, 'B', is a consonant. Example 2: Enter your first name:...
Write a Java method that takes an array of char and a String as input parameters...
Write a Java method that takes an array of char and a String as input parameters and and returns an boolean. The method returns true if we can find the input string inside the array by starting at any position of the array and reading either forwards or backwards.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT