(age>=18) is the condition if the expression is true value “Allowed”is assigned to voting else “Not Allowed” will be assigned to voting. Using Ternary Operator make this program. Programming Beginner To Advanced import java.util.*;class voting{ public static void main(String args[]) { String x; int n; Scanner sc= new Scanner(System.in); System.out.println("Enter the age"); n=sc.nextInt(); x=(n>=18)?"ALLOWED" :"NOT ALLOWED"; System.out.println(x); }} Share This: Facebook Twitter Google+ Stumble Digg Related Posts:Write a program in Java to accept two numbers and find the HCF/GCD and LCM of numbers. var aax_size='728x90'; var aax_pubname = 'javapba-21'; var aax_src='302'; Greatest Common Divisor/- The highest numb… Read MoreWrite a program in java to find the area and perimeter of triangle. var aax_size='728x90'; var aax_pubname = 'javapba-21'; var aax_src='302'; import java.util.*;class triangle{&nbs… Read MoreWrite a program in Java to print a numbers from Tribonacci series var aax_size='728x90'; var aax_pubname = 'javapba-21'; var aax_src='302'; A tribonacci series is one in which the su… Read MoreWrite a program in Java to accept the number of days and display the result after converting into number of years, number of months and the remaining number of days. var aax_size='728x90'; var aax_pubname = 'javapba-21'; var aax_src='302'; import java.util.*;class days{ … Read MoreWrite a program in java to print a numbers from Fibonacci series. var aax_size='728x90'; var aax_pubname = 'javapba-21'; var aax_src='302'; In Fibonacci series, next number is the su… Read More