Task 2 (20 pts) complex boolean expression Create project: HW3_Aries Submit java
ID: 3751197 • Letter: T
Question
Task 2 (20 pts) complex boolean expression Create project: HW3_Aries Submit java file: HW3_Aries.java Write a program that reads the month and the day from the user and prints whether or not someone born on that date is under the Aries astrological sign or not. Anyone born between and including March 21 and April 19 is Aries. You can assume that the month and day are given as integer numbers (e.g. do not worry about user enterring March) Hint: write the condition for an Aries date in March. Write the condition for April. Put these two together -Sample run: Enter the month: 3 Enter the day: 21 Aries. - Sample run: Enter the month: 4 Enter the day: 19 Aries. Sample run: Enter the month: 3 Enter the day: 27 Aries - Sample run: Enter the month: 4 Enter the day: 6 Aries Sample run: Enter the month: 3 Enter the day: 40 Not Aries. Sample run: Enter the month: 4 Enter the day: -5 Not Aries Sample run: Enter the month: 2 Enter the day: 27 Not Aries. Extra (for practice, not grade): recognize the month in other formats as well: Mar, March, 3, 03 Apr, April, 4, 04Explanation / Answer
import java.util.Scanner;
public class HW3_Aries {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the month: ");
int month=sc.nextInt();
System.out.print("Enetr the day: ");
int date=sc.nextInt();
if((month == 3 && date >= 21) || (month == 4 && date <= 19))
{
System.out.print("Aries");
}
else
{
System.out.print("Not Aries");
}
sc.close();
}
}
Sample Execution
Enter the month: 3
Enetr the day: 21
Aries
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.