Computer Science, asked by creamiepie, 1 year ago

\huge{Free 10 points}
.
.
.
.
(^o^)Just kidding (^o^)
Here's my question ⏩⏩

<b>Q.Write a JavaScript code to display the message 'Eligible for voting' in a message box,if the following conditions are true:-</b>
●The age should be >= 18
●The nationality should be Indian.
HINT:- Use if-else-if statement for this.



Answers

Answered by muakanshakya
1
\huge{\mathfrak{Heya!!}}
.
.
➖➖➖➖➖➖➖➖➖➖➖⬇️


import java.util.*;

class abc

{

public static void main(String args[])

{
Scanner sc = new Scanner(System.in);

System.out.println("Enter your age")

int age=sc.nextInt();

if(age>=18)
{

System.out.println("Eligible for voting");
}
else
{
System.out.println("Not eligible for voting");
}
}
}





Thanks. ;-)
Answered by siddhartharao77
4

<html>

<head>

<title>Eligible or not</title>

<script type="text/javascript">

function nationality()

{

var age;

age=Number(document.getElementById("Age").value);

if(age >= 18)

{

prompt(age,"You are indian");

}

else

{

prompt(age,"You are not indian");

}

}

</script>

</head>

<body>

<form>

Enter age:

<input id="Age" name="Age">

<br>

<button onclick="nationality()"> Click </button>

</form>

</body>

</html>



Hope it helps!


Attachments:
Similar questions