+ 1
Help, I dont know how to do this
Compute age by subtracting current year with the birth year, then identify if the age is qualified to vote or not,
4 Answers
+ 4
I believe that you don't have to ouput "What is your age?"
also task give you birthday year as input: you must compute age by substracting the birthday year to current year (2021), then do your logic with the age ^^
remove the related line and retry ;)
+ 2
Please show the language and your code try.Thanks
+ 2
{
public static void main(String args[])
{
int age;
Scanner sc=new Scanner(system.in);
System.out.print("What is your age?");
age=sc.nextInt();
if(age>=18)
System.out.println("You are eligible to vote.");
else
System.out.println("You are not eligible to vote.");
}
}
0