Help, I dont know how to do this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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,

18th Mar 2021, 1:15 PM
wenona saranza
wenona saranza - avatar
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 ;)
18th Mar 2021, 1:28 PM
visph
visph - avatar
+ 2
Please show the language and your code try.Thanks
18th Mar 2021, 1:18 PM
!Derrickee
!Derrickee - avatar
+ 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."); } }
18th Mar 2021, 1:18 PM
wenona saranza
wenona saranza - avatar
18th Mar 2021, 7:03 PM
A S Raghuvanshi
A S Raghuvanshi - avatar