Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.time.LocalDate; import java.time.Period; import java.util.Scanner; class AgeCalculator { public static void main ( String [ ] args ) { System.out.println ( Hello ,
import java.time.LocalDate;
import java.time.Period;
import java.util.Scanner;
class AgeCalculator
public static void mainString args
System.out.printlnHello Welcome to the Age Calculator!";
LocalDate cd LocalDate.now;
cd Current date
Scanner s new ScannerSystemin;
System.out.printlnEnter your birthdate: year month, day";
int y snextInt;
int m snextInt;
int d snextInt;
LocalDate bd LocalDate.ofymd;
bd Birth date
Period agePeriod Period.betweencdbd;
int age agePeriod.getYears;
Retrieve the years from the agePeriod
System.out.printlnYour age is agePeriod; Print the age
control access
if age Check if the age is greater than or equal to
System.out.printlnYou Have Access";
else
System.out.printlnYou Do Not Have Access";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started